boxgroups | R Documentation |
This function plots boxplots for various variables associated with ranges for various subgroups found into each variable
boxgroups(data,groups,box.opt=NULL,points.opt=NULL,box.width=0.3,
group.plot=c("min","max"),group.plot.type=c("b","l"),
names=NA,ticks=FALSE,x.gap=c(0,0),prop=FALSE,range=NA)
data |
A matrix or data frame to input. |
groups |
A vector of same length than the number of rows of |
box.opt |
Optional. Plotting options to be passed for the |
points.opt |
Optional. Plotting options to be passed for the |
box.width |
The relative width of the boxes, which also governs the gap between the box and the min-max lines of the variable. |
group.plot |
The type of points to be drawn to represent the variation of each subgroup in each variable. By default set to the minimal and maximal range of the subgroup to show its entire range. |
group.plot.type |
The type of plot to be drawn for the plot of each group alongside each boxplot. See |
names |
The names to be displayed under each boxplot + lines. Can be the names of the columns of |
ticks |
Logical. Should the ticks be displayed above each name? By default, |
x.gap |
Gap between the plotted data and the left and right axes. Default set to |
prop |
Logical. Do the boxplots need to be proportional with each other? By default, natural values are plotted ( |
range |
If |
This function first plot the boxplots of the different variables inputted. Then, bars of each of the defined subgroups in each variable are plotted alongside each boxplot, showing desired values describing each subgroup variation within each variable (minimal and maximal values by default, but there can also be other ones detailed below).
Graphical options to the boxplot
and points
formulas can be passed to customize the plot.
There is also a way to rescale all variables in order to be able to compare the variables and the distribution of each subgroup.
There are various ways to describe the variation of each subgroup alongside the global variable boxplot, which are not exclusive. One needs to specify them in the group.plot
argument with a character vector which can contain:
"min"
and "max"
the extreme range, encompassing all points
"mean"
the average value of the whole subgroup
"median"
the median of the whole subgroup
"sd-X"
to obtain points from both sides of the mean by a proportion X
(i.e., a number) of the standard deviation of the whole subgroup
"q-X"
to obtain the X
th percent quantile (i.e., a percentage)
"all"
to show all points of the subgroup
A<-runif(30,1,10)
B<-rexp(30)
C<-rnorm(30,0,1)
data<-data.frame(A=A,B=B,C=C)
groups<-sample(letters[1:4],30,replace=TRUE)
boxgroups(data=data,groups=groups,group.plot = c("all"))
boxgroups(data=data,groups=groups,points.opt=list("pch"=21,"col"=c("blue","red","green3","orange"),"bg"=c("blue","red","green3","orange"),"lwd"=2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.