Dear Arun and David,

Thank you very much for the response.

Arun's code works. Thank you very much.

David, I am sorry that I did not quite get the mean of your code, but still, 
thank you very much for helping.

Best regards,

ya 


> -----Original Message-----
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@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]]
> 
> ______________________________________________
> 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.
        [[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