[R] ggplot with sparse layout

Tom Wright tom at maladmin.com
Tue Jan 6 22:13:54 CET 2015


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]]



More information about the R-help mailing list