Re: [R] unable to force the vector format

2005-12-14 Thread Charles Plessy
On Wed, Dec 14, 2005 at 02:46:35PM +0100, Petr Pikal wrote :
 Hi
 
 is
 colMeans(your.df)
 
 what you want?
 
 BTW
 
 searching column mean in CRAN gives me the answer on first hit


Thank you all so much for all the answers I got. rowMeans is what I
needed.  I will bookmark the search page of CRAN for a later usage. As I
forgot the basics or R, I also forgot about CRAN :(

Best,

-- 
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


Re: [R] unable to force the vector format

2005-12-14 Thread Ido M. Tamir

 slides - read.table(slides.txt)
 slides [1:5,]
V1V2 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

maybe:
slides$mean - apply( slides[,2:8],1,mean)
close - abs(slides$mean)  0.03
slides[close,]

best wishes
ido

__
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


Re: [R] unable to force the vector format

2005-12-14 Thread jim holtman
Not too sure what you want the means of, but try

?colMeans
?rowMeans


On 12/14/05, Charles Plessy [EMAIL PROTECTED] 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,]
V1V2 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.html


Re: [R] unable to force the vector format

2005-12-14 Thread Petr Pikal
Hi

is
colMeans(your.df)

what you want?

BTW

searching column mean in CRAN gives me the answer on first hit

HTH
Petr




On 14 Dec 2005 at 22:12, Charles Plessy wrote:

Date sent:  Wed, 14 Dec 2005 22:12:16 +0900
From:   Charles Plessy [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Subject:[R] unable to force the vector format
Send reply to:  [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]

 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,]
 V1V2 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

Petr Pikal
[EMAIL PROTECTED]

__
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