Is there a way to plot multiple levels variables in R in separate graph with a simple code? -


i wonder if knows how execute code, each level separately plotted.

sites<-levels(orchardsprays$treatment) par(mfcol=c(4,2)) (i in 1:length(sites)) {   here_tmp<-sites[i]   plot(droplevels(subset(orchardsprays, site = here_tmp, select = c(treatment,decrease))))   } 

this output of code, same. want print different graphics each level in treatment

this output gives me. want different graphs of different levels. don't know why gives me same graphs...

i agree @simong it's not clear why you'd want have each level plotted on separate graph, here's way ggplot2, has nice system creating plots of each level of variable without code:

library(ggplot2)  ggplot(orchardsprays, aes(treatment, decrease)) +   geom_boxplot() +   facet_wrap(~treatment, scales="free_x", ncol=2) 

to put boxplots in single graph, remove last line:

ggplot(orchardsprays, aes(treatment, decrease)) +   geom_boxplot() 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -