[R] Names of list members in a plot using sapply
ggrothendieck at gmail.com
Fri Oct 30 13:04:45 CET 2009
You could lapply over the names:
junk <- lapply(names(list1), function(nm)
with(list1[[nm]], plot(x, y, type = "l", main = paste("Graphic
which is a slight improvement though that still involves dealing with
a list and its names separately.
On Fri, Oct 30, 2009 at 3:41 AM, Kenneth Roy Cabrera Torres
<krcabrer at une.net.co> wrote:
> Hi R users:
> I got this code to generate a graphic for each member of a lists.
> with(list1[[i]],plot(x,y,type="l",main=paste("Graphic of",names1[i]))))
> Is there a more elegant solution for not to use two separate lists?
> I would like to just use
> sapply(list1, somePlotfunction)
> and plot for each graphic in the title have the name of the member of
> the list.
> Thank you for your help.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help