[R] ggplot2 - facetting

From: Pedro de Barros <pbarros_at_ualg.pt>
Date: Tue, 25 Mar 2008 14:49:58 +0000


Dear All,

After having overcome the issue of legends (thanks, Thierry, once more), I am trying to use facetting, but here also I can not find how to do this. I do not want to use qplot, but rather the more flexible options. However, it seems I am doing still something pretty stupid, because I always get an error, even if it seems I am doing everything like the examples.

My code is below.
set.seed(123)
plotdata2<-data.frame(x=rep((1:4),4), y=rep(0.1*(1:4),4), group=sample(factor(rep(1:4,rep(4,4)), labels=c('Class1', 'Class2', 'Class3', 'Class4'))))
plotdata2 <- plotdata2[order(plotdata2[,'group']),] plot0<-ggplot()
layer1<-layer(data=plotdata2,
mapping=aes_string(x='x',y='y'),geom='point', stat='identity') scaleY<-scale_y_continuous()
scaleX <- scale_x_continuous()
Facets<-facet_grid(group ~ .)
plot1<-plot0+layer1 +scaleY + scaleX + facet_grid(group~.)

plot1

I always get the error message:
Error in check_formula(formula, varnames) :

   Formula contains variables not in list of known variables

Thanks for any help you can provide.

Best,
Pedro



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 25 Mar 2008 - 16:17:32 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 25 Mar 2008 - 16:30:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive