[R] using lapply

Uwe Ligges ligges at statistik.tu-dortmund.de
Thu Mar 10 10:38:15 CET 2011



On 10.03.2011 08:30, Arun Kumar Saha wrote:
> On reply to the post
> http://r.789695.n4.nabble.com/using-lapply-td3345268.html

Hmmm, can you please reply to the original post and quote it?
You mail was not recognized to be in the same thread as the message of 
the original poster (and hence I wasted time to answer it again).

Thanks,
Uwe Ligges




> Dear Kushan, this may be a good start:
>
> ## assuming 'instr.list' is  your list object and you are applying
> my.strat() function on each element of that list, you can use lapply
> function as
> lapply(instr.list, function(x) return(my.strat(x)))
>
> Here resulting element will again be another list with length is same as the
> length of your original list 'instr.list.'
>
> Instead if the returned object for my.strat() function is a single number
> then you might want to create a vector instead list, in that case just use
> 'sapply'
>
> HTH
>
> Arun,
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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