I think the easiest most straight forward way would be to just throw it
into a loop and subset the data on each loop around (untested code below
but I'm sure you get the gist).  ~Trevor

sex1<-unique(tips$sex)
day1<-unique(tips$day)
for (i in 1:length(sex1)){
   for (j in 1:length(day1)){


pdf(paste('example_',sex1[i],day1[j],'.pdf',sep=''))

data1<-subset(tips, sex==sex1[i] & day==day1[j])
sp <- ggplot(data1,aes(x=total_bill, y = tip/total_bill)) +
geom_point(shape=1)
plot(sp)
dev.off()
}
}



On Mon, Jun 30, 2014 at 10:23 AM, Bea GD <aguitatie...@hotmail.com> wrote:

> Hi,
>
> I'm working with tips data from reshape package.
>
>     library(reshape2)
>
> I'm saving my plots as pdf and I was wondering whether it was possible
> to print a different pdf for each 'wrapped' plot. Using the code below
> as an example, I'd like to get 8 independent pdf files for each sex ~
> day combination.
>
>     sp <- ggplot(tips,aes(x=total_bill, y = tip/total_bill)) +
>     geom_point(shape=1) +
>     facet_grid(sex ~ day)
>     plot(sp)
>
> Thanks a lot for your help!
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@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.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to