Re: [R] lapply

From: jim holtman <jholtman_at_gmail.com>
Date: Wed, 09 Jul 2008 11:38:34 -0400

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?

______________________________________________
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.
Received on Wed 09 Jul 2008 - 15:42:50 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 09 Jul 2008 - 16:31:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive