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 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
Post a Comment