[R] single plot statement, multiple plots
Hi R, par(mfrow=c(2,2)) x1=(1:5)^1; x2=(1:5)^2; x3=(1:5)^3; x4=(1:5)^4 I need to write a single plot statement, which creates 4 plots (for x1, x2, x3 and x4) in the graphics window, without using 'for' loop. Is this possible? Does 'do.call' help in this context? Or do I have any option in the 'plot' statement itself to do this? Thanks in advance, Shubha This e-mail may contain confidential and/or privileged i...{{dropped:13}} __ 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.
Re: [R] single plot statement, multiple plots
Try plot.zoo in which case you don't need the par: library(zoo) plot(zoo(cbind(x1, x2, x3, x4)), nc = 2) or plot(zoo(outer(1:5, 1:4, "^")), nc = 2) See ?plot.zoo, ?xyplot.zoo and the three vignettes in the zoo package. On Tue, May 6, 2008 at 9:47 AM, Shubha Vishwanath Karanth <[EMAIL PROTECTED]> wrote: > Hi R, > > > > par(mfrow=c(2,2)) > > x1=(1:5)^1; x2=(1:5)^2; x3=(1:5)^3; x4=(1:5)^4 > > > > I need to write a single plot statement, which creates 4 plots (for x1, > x2, x3 and x4) in the graphics window, without using 'for' loop. Is this > possible? Does 'do.call' help in this context? Or do I have any option > in the 'plot' statement itself to do this? > > > > Thanks in advance, > > Shubha > > This e-mail may contain confidential and/or privileged i...{{dropped:13}} > > __ > 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. > __ 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.
Re: [R] single plot statement, multiple plots
Thank you very much Gabor...Zoo is very powerful... Shubha Karanth | Amba Research Ph +91 80 3980 8031 | Mob +91 94 4886 4510 Bangalore * Colombo * London * New York * San José * Singapore * www.ambaresearch.com -Original Message- From: Gabor Grothendieck [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 06, 2008 7:40 PM To: Shubha Vishwanath Karanth Cc: [EMAIL PROTECTED] Subject: Re: [R] single plot statement, multiple plots Try plot.zoo in which case you don't need the par: library(zoo) plot(zoo(cbind(x1, x2, x3, x4)), nc = 2) or plot(zoo(outer(1:5, 1:4, "^")), nc = 2) See ?plot.zoo, ?xyplot.zoo and the three vignettes in the zoo package. On Tue, May 6, 2008 at 9:47 AM, Shubha Vishwanath Karanth <[EMAIL PROTECTED]> wrote: > Hi R, > > > > par(mfrow=c(2,2)) > > x1=(1:5)^1; x2=(1:5)^2; x3=(1:5)^3; x4=(1:5)^4 > > > > I need to write a single plot statement, which creates 4 plots (for x1, > x2, x3 and x4) in the graphics window, without using 'for' loop. Is this > possible? Does 'do.call' help in this context? Or do I have any option > in the 'plot' statement itself to do this? > > > > Thanks in advance, > > Shubha > > This e-mail may contain confidential and/or privileged i...{{dropped:13}} > > __ > 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. > This e-mail may contain confidential and/or privileged i...{{dropped:10}} __ 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.
Re: [R] single plot statement, multiple plots
"Shubha Vishwanath Karanth" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Hi R, > > par(mfrow=c(2,2)) > > x1=(1:5)^1; x2=(1:5)^2; x3=(1:5)^3; x4=(1:5)^4 > > I need to write a single plot statement, which creates 4 plots (for > x1, x2, x3 and x4) in the graphics window, without using 'for' loop. > Is this possible? Does 'do.call' help in this context? Or do I have > any option in the 'plot' statement itself to do this? > Have you considered lapply()? -- David Winsemius __ 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.
Re: [R] single plot statement, multiple plots
Wonderful...This works... lapply(list(x1,x2,x3,x4),plot,type="l") Thanks a lot! -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Winsemius Sent: Tuesday, May 06, 2008 7:55 PM To: [EMAIL PROTECTED] Subject: Re: [R] single plot statement, multiple plots "Shubha Vishwanath Karanth" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Hi R, > > par(mfrow=c(2,2)) > > x1=(1:5)^1; x2=(1:5)^2; x3=(1:5)^3; x4=(1:5)^4 > > I need to write a single plot statement, which creates 4 plots (for > x1, x2, x3 and x4) in the graphics window, without using 'for' loop. > Is this possible? Does 'do.call' help in this context? Or do I have > any option in the 'plot' statement itself to do this? > Have you considered lapply()? -- David Winsemius __ 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. This e-mail may contain confidential and/or privileged i...{{dropped:10}} __ 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.