[R] Problem with indexing
Bayesianbay@aol.com
Bayesianbay at aol.com
Thu Sep 12 12:33:50 CEST 2002
Dear List
I am having a bit of a problem getting a program to work.
For each of i=1 to n persons I have a matrix (different for each person) with
m rows.
What I want to do, is create m new data sets such that the first is made up
of the first row for each person from the original matrices, the second
contains the second row for each person from the original matrices etc etc up
to the mth new set containing the mth row from the original matrices for each
person.
Say the original matrix for each person can be indexed by xfinal.list[[i]]
I want to extract for each person in turn, the jth row, i.e.
xfinal.list[[i]][j,] then bind these n vectors into a new matrix.
I am a little confused as to how I can index the jth row from the ith person,
obviously I will need a loop
I thought I would be able to use something like:
for (j in 1:m) {
for (i in 1:n) {
vector.list[[i,j]]<-xfinal.list[[i]][j,]
} }
However I get the error that [[]] is an improper number of subscripts
Could anyone tell me how I can index it so that I can call up say the jth row
for the ith person?
As a secondary question, when using
do.call("rbind", args) is it possible to use indexing i.e do.call("rbind",
vector.list[[i,j]]) so that the vector from row j for each person are
combined into a new matrix?
Many thanks for any help
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 at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list