Skip to content
Back to formatted view

Raw Message

Message-ID: <OF4D5B3E02.81E079A9-ONC12576A3.00396D0F-C12576A3.0039CD14@precheza.cz>
Date: 2010-01-06T10:30:52Z
From: PIKAL Petr
Subject: Odp:  Choose variables according to index
In-Reply-To: <db80b30d1001060219r542cc9fn90ace0593c77ef3e@mail.gmail.com>

Hi

r-help-bounces at r-project.org napsal dne 06.01.2010 11:19:01:

> Hi
> 
> There must have someone already posted this question but I still have 
not
> figured how I could do this:
> Say I have var.1 var.2 var.3 which are large matrices. I would like to 
do
> the following loop:

Put your var.n to list

lll<- list(var.1, var.2, var.3)

and use list indexing

> 
> for(i in 1:3){
>   # Pick var.i and do something with it

temp.mat <- lll[[i]]

do stuff with temp.mat

> }
> 
> How can I tell R to do this?
> 
> Thanks for any comments.
> Hadassa
> 
>    [[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.