violinPlot: Violin plot

View source: R/violinPlot.R

violinPlotR Documentation

Violin plot

Description

Produce a quick violin plot with a boxplot inside from a data frame or matrix and if wanted a vector with group membership

Usage

violinPlot(df, group=NULL, same=TRUE, missing=TRUE, color="#F4A460", group1="Group1",
group2="Group2", legendLab="Group", title1="Title", numBreaks=10)

Arguments

df

vector, data frame or matrix

group

variable group (df$variable)

same

If you want one plot with all groups set to TRUE, otherwise FALSE

color

color when group is NULL (default "#F4A460")

colorBox

boxplot color for group (default = "Spectral" from RColorBrewer)

labList

default NULL uses factor levels as group membership label.Else list (p.eg c("group1", "group2"))

legendLab

Legend title label (default="Group")

title1

Plot title (default=NULL)

numBreaks

when there are more than 15 response values breaks are modified for better visualization (default=10)

Value

plot

Author(s)

Ariadna Angulo-Brunet (ariadna.angulo@uab.cat), Carme Viladrich

See Also

boxPlot, ggplot2

Examples

#generate some random data
x<-1:5
y<-c("Female", "Male")
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)

#default plot
violinPlot(df)

#change color 
violinPlot(df, color="green")

#by group 
violinPlot(df, gender)

#a plot for each group 
violinPlot(df, gender, out="rearrange")


AnguloB/SubscaleExplorer documentation built on Feb. 23, 2025, 1:05 a.m.