[R] For Loop Syntax

jim holtman jholtman at gmail.com
Mon Apr 27 19:00:32 CEST 2009


What do you expect this statement to do:

trial[i]       <- data.frame(A2$`i`)

what is `i` supposed to mean?  What is it that you want to do?

On Mon, Apr 27, 2009 at 10:25 AM, Bronagh Grimes
<Bronagh.Grimes at distinct.ie> wrote:
> Hi there,
>
>
>
> Just wondering if someone can help me with the correct syntax to use
> with for loops?
>
>
>
> I have split my original file by count, & wish to first of all assign
> new tables based on the splits.  Then I just want to create a new
> variable.  Please see code below.
>
>
>
> This code works outside of a loop so I am just trying to code so I don't
> have to repeat numerous times.
>
>
>
> Many thanks in advance,
>
> Bronagh
>
>
>
> A2 = split(A1,A1$count)
>
>
>
> for(i in 1:10){
>
> trial[i]       <- data.frame(A2$`i`)
>
> trial[i]$BLD[i]   <- triali$BLD
>
> trial[i]$count <- triali$BLD <- NULL
>
> }
>
>
>        [[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.
>



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

What is the problem that you are trying to solve?




More information about the R-help mailing list