rAmCharts - amBoxplot

Parameters

  • object: a vector, data.frame, a matrix, or a formula.
  • data: a data.frame, from which the variables in formula should be taken.
  • use.cols: a logical, for matrix only. Set to TRUE to display boxplot based on columns.
  • xlab: a character, label for x-axis.
  • ylab: a character, label for y-axis.
  • ylim: a numeric, y values range with sensible defaults.
  • names: a character, name on x-axis, if object is a vector.
  • col: a character, color(s) to be used to fill the boxplot.
  • horiz: a boolean, TRUE for an horizontal chart, FALSE for a vertical one.
  • id: a character, column name of id to identify outliers, if object is a dataframe.
  • : other parameters called in amOptions.

Basic example - formula

dataset <- get(x = "ChickWeight", pos = "package:datasets")
amBoxplot(weight~Diet, data=dataset)

Basic example - dataframe

don <- data.frame(a = 1:10, b = 1:5)
amBoxplot(don, ylim = c(0,15))

Basic example - matrix

mat <- matrix(nrow = 10, ncol = 5, rnorm(50))
## Warning in rnorm(50): '.Random.seed' is not an integer vector but of type
## 'NULL', so ignored
amBoxplot(mat)

Basic example - vector

amBoxplot(rnorm(100))

Horizontal boxplot

amBoxplot(weight~Diet, data=dataset, horiz = TRUE)

Display boxplot based on matrix’s rows

mat <- matrix(nrow = 10, ncol = 5, rnorm(50))
amBoxplot(mat, use.cols = FALSE)

Naming axis

amBoxplot(weight~Diet, data=dataset, xlab = "diet", ylab = "weight")

Y limits

amBoxplot(weight~Diet, data=dataset, ylim = c(0, 100))

Change color

amBoxplot(weight~Diet, data=dataset, col = "#CD1076")

amOptions

export

amBoxplot(weight~Diet, data=dataset, labelRotation = -45, export = TRUE)
#or
amBoxplot(weight~Diet, data=dataset, labelRotation = -45) %>>% 
  amOptions(export = TRUE)

exportFormat

amBoxplot(weight~Diet, data=dataset, labelRotation = -45, export = TRUE,
          exportFormat = "JPG")
#or
amBoxplot(weight~Diet, data=dataset, labelRotation = -45) %>>% 
  amOptions(export = TRUE, exportFormat = "JPG")

main and creditsPosition

amBoxplot(weight~Diet, data=dataset, labelRotation = -45, main = "My Barchart",
        mainColor = "#68838B", mainSize = 25, creditsPosition = "top-right")
#or
amBoxplot(weight~Diet, data=dataset, labelRotation = -45) %>>% 
  amOptions( main = "My Barchart",
        mainColor = "#68838B", mainSize = 25, creditsPosition = "top-right")

theme

amBoxplot(weight~Diet, data=dataset, 
          theme = "dark")
#or
amBoxplot(weight~Diet, data=dataset) %>>% 
  amOptions(theme = "dark")