cranvas (version 0.8.5)

qboxplot: Draw boxplots for several variables in the data or a continuous variable vs a categorical variable

Description

This function can draw side-by-side boxplots for all the variables in a data frame or boxplots for a continous variable vs a categorical variable.

Usage

qboxplot(vars, data, at = NULL, width = NULL, horizontal = FALSE, main = "", xlim = NULL, ylim = NULL, xlab = NULL, ylab = NULL, points = FALSE)

Arguments

vars
a list of variables (a character vector), or a formula; a one-sided formula like ~ x1 + x2 + x3 means to draw side-by-side boxplots for the variables in the right hand side, whereas a two-sided formula like y ~ x means boxplots of a continuous y against a categorical x
at
the locations of the boxplots (by default from 1 to p where p is the number of variables to plot or the number of levels of the categorical variable)
width
width(s) of boxes (do not have to be a same value if provided as a numeric vector); by default it is about 1/10 of the screen width
horizontal
horizontal or vertical boxplots
points
whether to add data points to the boxplot
data
a mutaframe created by qdata
main
the main title
xlim
a numeric vector of length 2 (like c(x0, x1)) for x-axis limits; it will be calculated from the data limits if not specified (NULL). Note when x0 > x1, the axis direction will be reversed (i.e. from larger values to small values)
ylim
y-axis limits; similar to xlim
xlab
x-axis title
ylab
y-axis title

Value

A boxplot

Details

Common interactions are documented in common_key_press. Note boxplots also supports brushing and can respond to brushing in other plots. When we brush in other plots which are based on the same data, there will be ``child'' boxplots in this plot showing the distributions of the brushed data.

See Also

Other plots: qbar; qdensity; qhist, qspine; qmval; qparallel; qtime

Examples

Run this code
library(cranvas)

### (1) some test cases
df <- qdata(as.data.frame(matrix(rnorm(1000), 200)))
qboxplot(~., df)
qboxplot(~., df, horizontal = TRUE)
qboxplot(~., df, at = (1:5)^2)  # at different locations
qboxplot(~., df, width = 0.1 * sample(5))  # different widths


### (2) flea data
data(flea, package = "tourr")
qflea <- qdata(flea)

## continuous vs categorical variable
qboxplot(tars1 ~ species, data = qflea)

## side-by-side boxplots for several continuous variables
qboxplot(~aede1 + aede2 + aede3, data = qflea)

## brush on other plots and we see little boxplots
qparallel(~., data = qflea)

qscatter(tars1, tars2, data = qflea)


## we can turn on the point layer too
qboxplot(tars1 ~ species, data = qflea, points = TRUE)

## show points with colors
qflea2 <- qdata(flea, color = species)
qboxplot(~aede1 + aede2 + aede3, data = qflea2, points = TRUE)

cranvas_off()

Run the code above in your browser using DataLab