How to boxplot full sample AND subsamples together in R? -
How to boxplot full sample AND subsamples together in R? -
i have reading scores 1 total sample , 10 subsamples (gender(2) race(5) = 10 combinations). want show 11 boxplots together. code below generates 10 boxplots lacks full sample's comparing boxplot.
how can place 11 boxplots in same plot/graphic share title, x-axis, y-axis, etc.?
ideally, how can place 10 subpopulation boxplots within 1 maximum-width population boxplot cuts across (is transparently layered over) 10 subpopulation boxplots allowing viewer graphically compare each subsample's 1q, median, , 3q of total sample? (see below illustration reddish boxplot represents total sample of hs1$read (1q: 44, median: 50, 3q: 60).)
setup:
hs1 = read.table("http://www.ats.ucla.edu/stat/data/hs1.csv", header = t, sep = ",") ## 10 boxplots (that wish combine 1 more representing total sample) boxplot( read ~ interaction(gender, race), data=hs1, las=2 )
boxplot( read ~ interaction(gender, race), data=hs1, las=2 ) bxpfull <- boxplot( hs1$read, plot=false) bxp(bxpfull, at= 5, add=true, boxwex=18, pars= list(boxcol="red",medcol="red", medbg="red", whiskcol="red", staplecol="red") )
if wanted transparent colors (which not graphics devices support) give transparent pinkish result:
bxp(bxpfull, at= 5, add=true, boxwex=18, pars= list(boxcol="#ff000050",medcol="#ff000050", medbg="#ff000050", whiskcol="#ff000050", staplecol="#ff000050") ,las=2)
r boxplot
Comments
Post a Comment