-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
project.org] On Behalf Of ya
Sent: Saturday, January 19, 2013 8:50 AM
To: r-help
Subject: [R] calculating mean matrix
Hi list,
Thank you vey much for reading this post.
I have a data frame, I am trying to split it into a couple of data
frame using one of the columns, say, x. After I get the data frames, I
am planning to treat them as matrices and trying to calculate an
element by element mean matrix. Could anyone give me some advice how to
do it?
So far, I know that if I have a couple of matrices, say
data1,data2,data3,data4...dataN, I can do it like this:
data=array(cbind(data1,data2,data3,data4,....dataN), c(2, 3, N))
#2 refers to row number of matrix, 3 refers to column number of matrix,
N refers to number of matrices to be averaged.
meanmtrx=apply(data,1:2,mean)
but I do not know how to use the resulting data frames with cbind().
Maybe there are other better ways. Any advice is appreciated.
Thank you very much.
Have a nice day.
ya
[[alternative HTML version deleted]]