[R] lapply

jim holtman jholtman at gmail.com
Wed Jul 9 17:38:34 CEST 2008


Yes.  It is the same syntax.  Can you provide an example of what you want to do.

> lapply(1:5, function(num){
+     .ret <- numeric(num)
+     for (i in 1:num) .ret[i] <- i*i
+     .ret
+ })
[[1]]
[1] 1

[[2]]
[1] 1 4

[[3]]
[1] 1 4 9

[[4]]
[1]  1  4  9 16

[[5]]
[1]  1  4  9 16 25

>
>


On Wed, Jul 9, 2008 at 11:26 AM, Rajasekaramya <ramya.victory at gmail.com> wrote:
>
> hi
>
> Can i use a for loop with in the lapply..if so could u plz let me know the
> syntax.....
>
> Ramya
> --
> View this message in context: http://www.nabble.com/lapply-tp18363288p18363288.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?



More information about the R-help mailing list