[R] ggplot with sparse layout
ONKELINX, Thierry
Thierry.ONKELINX at inbo.be
Tue Jan 6 23:58:07 CET 2015
Dear Tom,
Does ggplot(data,aes(x=x,y=y))+geom_point(aes(color=group))+facet_wrap(~group + id) gives what you need?
Note that facet_grid by design aligns the subplots into rows and columns with the same level.
Best regards,
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
Thierry.Onkelinx op inbo.be
www.inbo.be
To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey
________________________________________
Van: R-help [r-help-bounces op r-project.org] namens Tom Wright [tom op maladmin.com]
Verzonden: dinsdag 6 januari 2015 22:13
Aan: R. Help
Onderwerp: [R] ggplot with sparse layout
Hi,
I would like to plot the following data such that each plot represents the
data from a single id and the plots are grouped according to the group
variable.
data<-data.frame(id=factor(rep(1:6,each=3)),
group=factor(c('a','a','b','c','c','c')),
x=runif(18,0,10),
y=rnorm(18,0,1))
The following ggplot nearly works but I would prefer to not plot the
missing combinations, i.e. each row will be a different length.
ggplot(data,aes(x=x,y=y))+geom_point(aes(color=group))+facet_grid(group~id)
Is this possible using ggplot or will I need to craft something using grid?
Thanks for any ideas.
Tom
[[alternative HTML version deleted]]
______________________________________________
R-help op r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.
Disclaimer<https://drupal.inbo.be/nl/disclaimer-mailberichten-van-het-inbo>
More information about the R-help
mailing list