How to names lists under list when using lapply?
问题 I have a two nested loop which I want to do it with lapply instead of for loops. I have made up the following simple example: a<-as.list(c(1,2)) b<-as.list(c(6,7)) results<-lapply(a, function(x) lapply(b, function(y) x+y)) > results [[1]] [[1]][[1]] [1] 7 [[1]][[2]] [1] 8 [[2]] [[2]][[1]] [1] 8 [[2]][[2]] [1] 9 how can I assign names to this list, I can assign names to the first level using names(result)<-a, but I do not know how to do it for the second level. And naming should be done in