boxPlot | R Documentation |
Produce a quick boxplot from a data frame or matrix and if wanted a vector with group membership.
boxPlot(df, group=NULL, out="default", missing=TRUE, color="#F4A460", labList=TRUE, legendLab="Group", title1="", xOrder=TRUE, numBreaks=10)
df |
vector, data frame or matrix |
group |
A vector of the same length as df (p.ex df$group) Default (NULL) |
out |
For groups. If "default" a boxplot with all groups is printed. If "rearranged" one graph with a plot for each group is printed |
missing |
If FALSE, na.omit is used before ploting for variable group. Default TRUE |
labList |
default NULL uses factor levels as group membership label.Else list (p.eg c("group1", "group2")) |
color |
color when group is NULL (default "#F4A460") |
colorBox |
boxplot color for group (default = "Spectral" from RColorBrewer) |
alpha |
transparency, defaults .3 |
legendLab |
Legend title label (default="Group") |
title1 |
Plot title (default="") |
xOrder |
x labels ordered alphabetically (default=TRUE) |
numBreaks |
when there are more than 15 response values breaks are modified for better visualization (default=10) |
plot |
Single plot |
pdf |
One plot per each group (same=FALSE) |
Ariadna Angulo-Brunet (ariadna.angulo@uab.cat), Carme Viladrich
violinPlot
, ggplot2
#generate some random data
x<-1:5
y<-1:2
v1<-sample(x,80,replace=TRUE)
v2<-sample(x,80,replace=TRUE)
v3<-sample(x,80,replace=TRUE)
v4<-sample(x,80,replace=TRUE)
gender<- sample(y, 80, replace=TRUE)
df <- data.frame(v1, v2,v3,v4)
#Run boxplot
boxPlot(df)
#Run boxplot by group
boxPlot(df, group=gender, labList=c("Male", "Female"), legendLab="Gender", title1="Boxplot by gender")
#Run a boxplot for each group
boxPlot(df, group=gender, out="rearrange")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.