[R] single plot statement, multiple plots

Shubha Vishwanath Karanth shubhak at ambaresearch.com
Tue May 6 16:33:44 CEST 2008


Wonderful...This works...

lapply(list(x1,x2,x3,x4),plot,type="l")

Thanks a lot!
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of David Winsemius
Sent: Tuesday, May 06, 2008 7:55 PM
To: r-help at stat.math.ethz.ch
Subject: Re: [R] single plot statement, multiple plots

"Shubha Vishwanath Karanth" <shubhak at ambaresearch.com> wrote in
news:A36876D3F8A5734FA84A4338135E7CC30361BD28 at BAN-MAILSRV03.Amba.com: 

> 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 at 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}}



More information about the R-help mailing list