[R] how to specify ggplot2 facet plot order

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Wed Feb 27 11:36:45 CET 2008


Chris,

You can use the as.is or stringsAsFactors argument in read.csv to
prevent that strings are converted into factors. See ?read.csv for the
details.

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 Chris Friedl
Verzonden: woensdag 27 februari 2008 11:23
Aan: r-help op r-project.org
Onderwerp: Re: [R] how to specify ggplot2 facet plot order


Hi Thierry

thanks for your help. I've been searching the R-help archives for posts
by
you and Hadley as a way to learn ggplot details so I appreciate your
help to
the R community.

I wasn't aware of the levels option in the factors function. In my real
application I get the data using read.csv and factor assignment happens
automagically. Is there a way to control the level assignments at the
input
stage? Can't see anything to that effect in help.

Sorry for the cut & paste error ... getting used to Xemacs on Windows. I
used emacs years ago on Unix but  now my environment is Windows. So far
I
find the Xemacs/Ess combo to be very powerful and flexible. Just need to
get
used to C-x C-c etc differences.


ONKELINX, Thierry wrote:
> 
> Chris,
> 
> The order of the facets row or column depend on the order in the
> associated factor. The code below is what you want. Note that I have
> changed 'cases' in 'series' because your example was not reproducible
as
> a definition of 'cases' was missing.
> 
> library(ggplot2)
> series <- c('C2','C4','C8','C10','C15','C20')
> series <- factor(series, levels = series)
> ids <- c('ID1','ID2','ID3')
> mydata <-
> data.frame(SERIES=rep(series,30),ID=rep(ids,60),VALUE=rnorm(180))
> qplot(VALUE, data = mydata, geom="density", facets=SERIES ~ ID) 
> 
> Thierry
> 

-- 
View this message in context:
http://www.nabble.com/how-to-specify-ggplot2-facet-plot-order-tp15705404
p15710275.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.



More information about the R-help mailing list