Rainer M Krug
2008-Jan-26 13:15 UTC
[R] using facet_grid() from ggplot2 with additional text in labels
Hi I am using ggplot2 at the moment and I must say it is definitely better then ggplot - good work. My problem is that I am using facet_grid() in the following way: > p <- ggplot(ssq, aes(x=year, y=-log(ssq))) > p + geom_point() + facet_grid(me*gi~cs*rz) and it works nicely, except that I would like to have, in naddition to the values of me, gi, cs and rz the name of the variable. I.e: if gi is 1, 2 and 3 I would like to have "gi = 1:", "gi = 2" and "gi = 3" as labels of the p[anels. I did it with ggplot, but I don't remember and I have lost the code ... Just a small comment on the package: as I am using emacs with ess, I have to press "_" twice to get the underscore in the commands (as the first one is replaced with "->" and then reverted to "_") - would it be possible to change these in the next release with "." (but still provide an alias with "_")? Thanks a lot Rainer
hadley wickham
2008-Jan-27 17:43 UTC
[R] using facet_grid() from ggplot2 with additional text in labels
> I am using ggplot2 at the moment and I must say it is definitely better > then ggplot - good work. > > My problem is that I am using facet_grid() in the following way: > > > p <- ggplot(ssq, aes(x=year, y=-log(ssq))) > > p + geom_point() + facet_grid(me*gi~cs*rz) > > and it works nicely, except that I would like to have, in naddition to > the values of me, gi, cs and rz the name of the variable. I.e: if gi is > 1, 2 and 3 I would like to have "gi = 1:", "gi = 2" and "gi = 3" as > labels of the p[anels. I did it with ggplot, but I don't remember and I > have lost the code ...ggopt(strip.text = function(variable, value) paste(variable, value, sep="= "))> Just a small comment on the package: as I am using emacs with ess, I > have to press "_" twice to get the underscore in the commands (as the > first one is replaced with "->" and then reverted to "_") - would it be > possible to change these in the next release with "." (but still provide > an alias with "_")?I know it's a pain but I think emacs users need to change their ways (and default settings) because as time goes by I think you'll see increasing numbers of packages using _ instead of . to prevent conflicts with S3. It would be nice if R had a standard convention for separating words in functions. Hadley -- http://had.co.nz/
ONKELINX, Thierry
2008-Jan-28 10:06 UTC
[R] using facet_grid() from ggplot2 with additional text in labels
Dear Rainer, I think you'll have to recode the labels of the levels to get the output that you want. levels(ssq$gi) <- c("gi = 1", "gi = 2", "gi = 3") HTH, Thierry ------------------------------------------------------------------------ ---- ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 Thierry.Onkelinx op inbo.be www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -----Oorspronkelijk bericht----- Van: r-help-bounces op r-project.org [mailto:r-help-bounces op r-project.org] Namens Rainer M Krug Verzonden: zaterdag 26 januari 2008 14:15 Aan: r-help; hadley wickham Onderwerp: [R] using facet_grid() from ggplot2 with additional text in labels Hi I am using ggplot2 at the moment and I must say it is definitely better then ggplot - good work. My problem is that I am using facet_grid() in the following way: > p <- ggplot(ssq, aes(x=year, y=-log(ssq))) > p + geom_point() + facet_grid(me*gi~cs*rz) and it works nicely, except that I would like to have, in naddition to the values of me, gi, cs and rz the name of the variable. I.e: if gi is 1, 2 and 3 I would like to have "gi = 1:", "gi = 2" and "gi = 3" as labels of the p[anels. I did it with ggplot, but I don't remember and I have lost the code ... Just a small comment on the package: as I am using emacs with ess, I have to press "_" twice to get the underscore in the commands (as the first one is replaced with "->" and then reverted to "_") - would it be possible to change these in the next release with "." (but still provide an alias with "_")? Thanks a lot Rainer ______________________________________________ R-help op 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.
Possibly Parallel Threads
- ggplot2: proper use of facet_grid inside a function
- ggplot2: facet_grid with different vertical lines on each facet
- ggplot2, geom_hline and facet_grid
- ggplot2: facet_grid with only one level does not display the graph with the facet_grid level in title
- ggplot2 - facet_grid and facet_wrap