[R] lapply assign to list

Kenneth Roy Cabrera Torres krcabrer at une.net.co
Wed Dec 2 20:17:39 CET 2009


Hi R users:

I got an error that "l1" is not found.

This is a sample code:

f1<-function(i,l1){
  print(l1[[i]])
  l1[[i+1]]<<-i
  return(i)
}

z1<-list(x=100,NULL,a=c(1,1))
lapply(1:3,f1,l1=z1)

My final goal is to update the value of
each list component to use it in the following
step.

I see that print function founds l1[[1]],
but the assign instruction not.

Thank you for your help.

Kenneth

PD: R.Version()$version.string
[1] "R version 2.10.0 Patched (2009-11-24 r50556)"
on Ubuntu linux.




More information about the R-help mailing list