I have 2 lists, and inside each there are two more lists containing data frames (in other words, nested lists). I want to build each data frame and call it a base on the names of both primary and nested lists.
For example, let's say that we have:
a=list(
list(a=data.frame(x=rpois(5,1),y=rpois(5,1)),
b=data.frame(x=rpois(5,1),y=rpois(5,1))),
list(c=data.frame(x=rpois(5,1),y=rpois(5,1)),
d=data.frame(x=rpois(5,1),y=rpois(5,1))))
And we have the names of the main list:
names(a)=c("alpha","bravo")
Inside the two primary lists alphaand bravowe have two more lists: charlieand delta:
for(i in 1:length(a)) {
names(a[[i]])=c("charlie","delta") }
lapply , (alpha bravo) (charlie delta) . , : alpha_charlie, alpha_delta, bravo_charlie bravo_delta.
lapply(a,function(i) {
lapply(names(i), function(j) {
ggplot()+
geom_point(data=i[[j]],aes(x,y))+
opts(title=paste(names(i),j,sep="_"))
} ) } )
. !