Re: [R] Names of list members in a plot using sapply

2009-10-30 Thread Gabor Grothendieck
You could lapply over the names: junk <- lapply(names(list1), function(nm) with(list1[[nm]], plot(x, y, type = "l", main = paste("Graphic of", nm 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, Ken

Re: [R] Names of list members in a plot using sapply

2009-10-30 Thread jim holtman
sapply(names(list1), function(.data.){ with(list1[[.data.]], plot(x, y, type='l', main=paste("Graphic of", .data))) }) On Fri, Oct 30, 2009 at 3:41 AM, Kenneth Roy Cabrera Torres wrote: > Hi R users: > > I got this code to generate a graphic for each member of a lists. > > list1<-list(A=data.

[R] Names of list members in a plot using sapply

2009-10-30 Thread Kenneth Roy Cabrera Torres
Hi R users: I got this code to generate a graphic for each member of a lists. list1<-list(A=data.frame(x=c(1,2),y=c(5,6)),B=data.frame(x=c(8,9),y=c(12,6))) names1<-names(list1) sapply(1:length(list1),function(i) with(list1[[i]],plot(x,y,type="l",main=paste("Graphic of",names1[i] Is there a m