From: jim holtman <jholtman_at_gmail.com>

Date: Thu 15 Dec 2005 - 00:49:34 EST

Date: Thu 15 Dec 2005 - 00:49:34 EST

Not too sure what you want the means of, but try

?colMeans

?rowMeans

On 12/14/05, Charles Plessy <charles-r-nospam@plessy.org> wrote:

*>
*

> Dear all,

*>
**> I am so ashamed to pollute the list with a trivial question, but it is a
**> long time I have not used R, and I need a result in the next one or two
**> hour...
**>
**> I have a table which I have loaded with read.table, and I want to make
**> the mean of its columns.
**>
**> > slides <- read.table("slides.txt")
**> > slides [1:5,]
**> V1 V2 V3 V4 V5 V6 V7 V8
**> 1 PLB00090AA02 0.147 0.018 0.046 0.064 -0.018 -0.008 -0.063
**> 2 PLB00090BC08 0.171 0.011 -0.001 0.009 0.052 0.032 -0.065
**> 3 PLB00090CG02 0.029 -0.014 -0.042 0.006 0.024 -0.009 -0.043
**> 4 PLB00091AA08 0.033 0.050 -0.022 -0.002 0.038 0.015 -0.037
**> 5 PLB00091BE02 0.183 0.039 0.052 -0.014 -0.034 -0.037 0.037
**>
**> but I can not get the mean :
**>
**> > mean(slides [1,2:8])
**> V2 V3 V4 V5 V6 V7 V8
**> 0.147 0.018 0.046 0.064 -0.018 -0.008 -0.063
**>
**> obviously, I fail to tell R that I am using a vector.
**>
**> > y<- c(1,2,3,4)
**> > mean(y)
**> [1] 2.5
**>
**> but as.vector does not solve my problem
**>
**> > lapply(as.vector(slides[1,2:8]),sum)
**> $V2
**> [1] 0.147
**>
**> $V3
**> [1] 0.018
**>
**> $V4
**> [1] 0.046
**>
**> $V5
**> [1] 0.064
**>
**> $V6
**> [1] -0.018
**>
**> $V7
**> [1] -0.008
**>
**> $V8
**> [1] -0.063
**>
**> In the end, I would like to use lapply to fill a new column in the table
**> with the means.
**> (and then extract the closest ones to zero...)
**>
**> Once again, sorry for this mail, whose answer is probably trivial, but it
**> would
**> be an enormous help if somebody could sent it to me!
**>
**> --
**> Charles
**>
**> ______________________________________________
**> R-help@stat.math.ethz.ch mailing list
**> https://stat.ethz.ch/mailman/listinfo/r-help
**> PLEASE do read the posting guide!
**> http://www.R-project.org/posting-guide.html
**>
*

-- Jim Holtman Cincinnati, OH +1 513 247 0281 What the problem you are trying to solve? [[alternative HTML version deleted]] ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.htmlReceived on Thu Dec 15 00:56:07 2005

*
This archive was generated by hypermail 2.1.8
: Thu 15 Dec 2005 - 02:44:59 EST
*