[R] list of matrices
arun
smartpink111 at yahoo.com
Wed Jan 2 23:34:05 CET 2013
Hi,
Check this link
http://tolstoy.newcastle.edu.au/R/help/05/04/1765.html
set.seed(15)
list1<-lapply(1:3,function(i) matrix(sample(1:10,6,replace=TRUE),ncol=i) )
lapply(list1,function(x) colMeans(x,na.rm=TRUE))
[[1]]
#[1] 6.666667
#[[2]]
#[1] 6.333333 6.000000
##
#[[3]]
#[1] 7.0 9.0 7.5
A.K.
----- Original Message -----
From: eliza botto <eliza_botto at hotmail.com>
To: "r-help at r-project.org" <r-help at r-project.org>
Cc:
Sent: Wednesday, January 2, 2013 5:16 PM
Subject: [R] list of matrices
dear useRs,
i have a list containing 16 matrices. i want to calculate the column mean of each of them.
i tried
>sr <- lapply(s,function(x) colMeans(x, na.rm=TRUE))
but i am getting the following error
>Error in colMeans(x, na.rm = TRUE) : 'x' must be numeric
can it be done in any other way? and why i am getting this error??
thanks in advance..
elisa
[[alternative HTML version deleted]]
______________________________________________
R-help at 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.
More information about the R-help
mailing list