From: Adaikalavan Ramasamy (ramasamy@stats.ox.ac.uk)
Date: Mon 29 Jul 2002 - 19:49:25 EST
Message-id: <005101c236e5$398da4f0$a81401a3@stats.ox.ac.uk>
I am assuming your outputs are not scalar. You might want to use list()
function. Try :
xy.list <- list(NULL) # initialise an list with null attributes
for (i in 1:10) {
xy.list[[i]] <- X%*%Y }
Note the double square bracket. So xy.list[[8]] should extract the X%*%Y
values for the 8th person.
Hope this helps.
----- Original Message -----
From: <laura@bayesian-bay.freeserve.co.uk>
To: <r-help@stat.math.ethz.ch>
Sent: Monday, July 29, 2002 10:04 AM
Subject: [R] creating an index vector within a 'for' loop
> Dear list
>
> I have what is probably a very simple question that I can't seem to solve.
I basically want to create a vector at the end of a 'for' loop that will
store the output for each person and which I can recall after the loop has
run. This will require some sort of indexing.
>
> X and Y are matrices defined earlier for each person (within the for loop
but I'm not writing it here to cut irrelevant information)
>
> for (i in 1:10) {
> XY[i]<-X%*%Y
> }
>
> Could someone tell me how I can create the matrix that will contain the
output for each of the 10 people?
>
> Many thanks in advance
> Laura
>
>
> _______________________________________________________________________
>
>
>
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-.-
> 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@stat.math.ethz.ch
>
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._
>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
This archive was generated by hypermail 2.1.3 : Tue 01 Jun 2004 - 09:31:04 EST