Skip to content
Prev 302164 / 398503 Next

apply function over same column of all objects in a list

Hi Arun,
if you name the data.frame in the list, e.g.
mango <- list( y=c(4,5,3,2,1,8), bw=c(4,18,12,3,4,9),
nn=paste0("a",1:6),target=data.frame(coconut=1:6))
banana <- list(target=data.frame(coconut=c(1,2,18,16,15)), y=c(4,5,9,2,1),
bw=c(4,18,22,3,4), nn=paste0("a",1:5))
pineapple <- list(target=data.frame(coconut=c(4,6,9)), y=c(8,24,12),
bw=c(14,31,36), nn=paste0("a",1:3))
list6<-list(mango,banana,pineapple)

then
sapply(lapply(list5,"[[","target"),max)

still works.

Regards

Am 02.08.2012 20:21, schrieb arun kirshna [via R]: