R: How to have a violin plot, box-percentile plot that takes into account sample size? -
to use simple example, let's say:
a = rnorm(10) b = rnorm(100) c = rnorm(500) library(vioplot) vioplot(a,b,c) my question how create such graph takes account sample size. 'c' has higher sample size 'a', there way violin plot 'c' can show "bigger" violin 'a'? density distribution goes across 3 classes suppose, though entire distribution shape of 'a' , 'c' may equal, rather showing identical images show 'a' being of smaller shape stature 'c' , 'b' due smaller sample size.
it's unfortunate vioplot doesn't accept vectors of parameters. here's workaround. helpful features in vioplot() workaround at , wex parameters along add=t. plot each violin individually parameters shape them way want. may need make adjustments way scale sample size use wex.
n<-c(100,1000) size<-scale(sqrt(n),center=f) x1<-rnorm(n[1]) x2<-rnorm(n[2]) #initialize empty plot plot(0:3,rep(0,4),type='l',xlim=c(0,3),ylim=c(-4,4),ylab="",xlab="",xaxt="n",lty=3) # fill in violins @ specific x locations using `wex` parameter size vioplot(x1,at=1,wex=size[1],add=t,col="darkgray") vioplot(x2,at=2,wex=size[2],add=t,col="darkgray") axis(1,at=1:2,labels=c("mon","tues")) 
Comments
Post a Comment