[R] lapply assign to list
Kenneth Roy Cabrera Torres
krcabrer at une.net.co
Wed Dec 2 20:34:12 CET 2009
Yes...
It assing to each list component the index...
As you see I want to modify each component of the list
so I can use it at the following step o the lapply procedure.
El mié, 02-12-2009 a las 17:23 -0200, Henrique Dallazuanna escribió:
> Try this:
>
> z1[] <- 1:3
>
>
>
> On Wed, Dec 2, 2009 at 5:17 PM, Kenneth Roy Cabrera Torres
> <krcabrer at une.net.co> wrote:
> > 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.
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>
>
More information about the R-help
mailing list