Dear R-helpers ,

I have a simple loop as follows, however, to be more efficient, I would like
to use any apply functions (tapply, I suppose)
But how can I do this ? I am not very clear about this.

# Z is a P * Q matrix
# so for each row of Z, I would like to pull out only some of the elements,
and save as a separate matrix under a list
# index is a vector with length smaller than Q, but the index could be
different for each row of Z.

for (i in 1:P)
{
  tmp = matrix(Z[i, index], nrow=1)
  tmpr[[i]]=tmp
}

any help is highly appreciated!!

Thank you all

Carrie

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to