[R] newbie: remove column with low mean from a matrix
Tord Snall
tord.snall at ebc.uu.se
Tue Mar 5 17:49:14 CET 2002
Dear all,
Sorry to bother you with one more newbie question.
I have a dataobject with several hundreds of columns. I want to remove
columns with a mean of the column values below a certain value:
> a<- c(1,2,3,4,5,6)
> b<-c(2,4,6,8,10,12)
> c<- c(3,6,9,12,15,18)
> test<- as.matrix(cbind(a, b, c))
> mean(a)
[1] 3.5
> mean(b)
[1] 7
> mean(c)
[1] 10.5
Say the "certain value" is 5, I would like a new matrix as follows:
> new.test
b c
[1,] 2 3
[2,] 4 6
[3,] 6 9
[4,] 8 12
[5,] 10 15
[6,] 12 18
I have searched in the help archive, in help files, and in the
documentation without finding it.
Thanks in advance!
Yours sincerely,
Tord Snäll
-----------------------------------------------------------------------
Tord Snäll
Avd. f växtekologi, Evolutionsbiologiskt centrum, Uppsala universitet
Dept. of Plant Ecology, Evolutionary Biology Centre, Uppsala University
Villavägen 14
SE-752 36 Uppsala, Sweden
Tel: 018-471 28 82 (int +46 18 471 28 82) (work)
Tel: 018-25 71 33 (int +46 18 25 71 33) (home)
Fax: 018-55 34 19 (int +46 18 55 34 19) (work)
E-mail: Tord.Snall at ebc.uu.se
http://www.vaxtbio.uu.se/resfold/snall.htm
------------------------------------------------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list