Re: [R] for loop with global variables

From: jim holtman <jholtman_at_gmail.com>
Date: Thu, 28 Apr 2011 10:31:27 -0400

Yes you can, but there is not enough explaination as to what you really want to do. I would suggest that you look at using a 'list' instead of individual objects:

myList <- list(output.1 = rbind('a','b'), output.2 = rbind('c','d'), ...)

Then you can use 'lapply' to operation on the elements.

On Thu, Apr 28, 2011 at 10:16 AM, ivan <i.petzev_at_gmail.com> wrote:
> Hi,
>
> is there a possibility to use global variables in a for loop. More
> specifically, I want to do the following:
>
> output.1<-rbind("a","b")
> output.2<-rbind("c","d")
> output.3<-rbind("e","f")
> .
> .
> .
> output.n<-rbind(...,...)
>
> next I want to create a data frame with two columns:
>
> Outputs
> Values  output.1 "a","b"  output.2 "c","d"  output.3 "e","f"  .
>  .
>  output.n …,…
> My problem is that I do not how to define a loop over global variables.
> Anybody an idea?
>
> Thanks.
>
>        [[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
Data Munger Guru

What is the problem that 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 Thu 28 Apr 2011 - 14:43:01 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 Thu 28 Apr 2011 - 15:20:35 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