[R] Taking mean of 3 cols in data frame : error
Abhishek Pratap
abhishek.vit at gmail.com
Sat Jan 30 06:29:38 CET 2010
Hi All
I am seeing quite a silly thing for which I dont have much of
explanation. I want to take per row mean of 3 columns of a data frame.
What I am getting is all NA in the result. Here is what I am doing
apply(a[,1:3],1,mean)
I get warnings.
In mean.default(newX[, i], ...) :
argument is not numeric or logical: returning NA
I am not sure how it thinks the values are not numeric. May be I had a
long day and not able get something fairly obvious.
==========
summary(a)
animal1_wt animal2_wt animal3_wt
0 : 5448 0 : 5295 0 :
5501
0.232266 : 7 0.17356 : 5 6.22424 : 6
1.05487 : 6 0.00630758: 4 0.0395818 : 5
0.258336 : 5 0.0131442 : 4 4.14949 : 5
0.372308 : 5 0.0143924 : 4 0.00964998: 4
0.00926343: 4 0.017208 : 4 0.0172297 : 4
(Other) :15696 (Other) :15855 (Other) :15646
More information about the R-help
mailing list