[R] For Loops

Isabel Jones statsonthebrain at yahoo.com
Tue Oct 30 15:18:40 CET 2001

Hi all

Perhaps someone could help me?

I am running a loop from i=1 to n

In my data.frame I have a list of i.d's (i=1 to n) and
each i.d has 2
rows of data (representing 2 time points) e.g.

id  Y   X1   X2
 1   1   0     0 
 1   0   0     0
 2   1   1     0
 2   1   1     0

I am wanting to put into my 'for' loop, a line which
can pick out the
rows where id=i and call this a temporary name while
it executes some
commands beforing moving on to the next i. I'm not
sure what command I
can use to locate these rows where id=i and store them
in a temporary

Also when I have say a matrix consisting of all values
of Y - how can I
refer to the Y for person i i.e. Yi
I have seen in the R information that I can use
Is it possible to write say Y[[i]]<-x[[i]]*5

Can somebody point me in the right direction as to how
to use indexing?

Cheers to all


r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list