you have to print the object

gg <- data.frame(datadate=1:4, spread=5:8)
>           pdf()
>           for (i in 1:3) {
+               d <- qplot(gg$datadate, gg$spread, geom="line", main=i)
+           print(d)}
>           dev.off()

On Tue, Mar 23, 2010 at 1:14 PM, Bos, Roger <roger....@rothschild.com> wrote:
> I am trying to create plots within a for loop and output them to a pdf.
> Here is a working example using plot:
>
>          gg <- data.frame(datadate=1:4, spread=5:8)
>          pdf()
>          for (i in 1:3) {
>              plot(gg$datadate, gg$spread, main=i)
>          }
>          dev.off()
>
> I am trying to learn more about ggplot2 so I try a slight modification
> and it doesn't work.  Anyone know how to do this using qplot in ggplot2?
>
>
>           gg <- data.frame(datadate=1:4, spread=5:8)
>          pdf()
>          for (i in 1:3) {
>              qplot(gg$datadate, gg$spread, geom="line", main=i)
>          }
>          dev.off()
>
> ***************************************************************
>
> This message is for the named person's use only. It may\...{{dropped:20}}
>
> ______________________________________________
> 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.
>



-- 
Stephen Sefick

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

                                                                -K. Mullis

______________________________________________
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