HI Elisa, The data that you sent to me is a matrix, (not the list containing 16 matrices).
source("Elizanew.txt") is.matrix(dat1) #[1] TRUE dim(dat1) #[1] 558 12 dat1<-na.omit(dat1) nrow(dat1) #[1] 508 colMeans(dat1) #[1] 970.1942 892.5579 893.3180 1629.0733 5692.8488 12529.8313 #[7] 13965.5763 9270.4147 4352.4091 2082.5329 1441.8123 1158.6669 A.K. ________________________________ From: eliza botto <eliza_bo...@hotmail.com> To: "smartpink...@yahoo.com" <smartpink...@yahoo.com> Sent: Wednesday, January 2, 2013 5:41 PM Subject: RE: [R] list of matrices dear arun, can u please try your command on the following elisa > Date: Wed, 2 Jan 2013 14:34:05 -0800 > From: smartpink...@yahoo.com > Subject: Re: [R] list of matrices > To: eliza_bo...@hotmail.com > CC: r-help@r-project.org > > 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_bo...@hotmail.com> > To: "r-help@r-project.org" <r-help@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@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. > ______________________________________________ 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.