[R] Warnings by functions mean(), median()

mailpuls@gmx.net mailpuls at gmx.net
Sat Feb 19 12:48:35 CET 2005


Hello,

following functions doesnt work correct with my data: median(), geo.mean().

My datafiles contain more than 10.000 lines and six columns from a 
flow-cytometer-measurment. I need the arithmetic and geometric mean and 
median. For the calculation of the geometric mean i wrote following 
function:

     fix(geo.mean)

     function(x)
     {
         n<-length(x)
         gm<-prod(x)^(1/n)
         return(gm)
     }

The function median() error tells me "need numeric data". The data are 
numeric. The function geo.mean() gave out "[1] NaN". What are the 
reasons and what are the solutions?

I'am a newbie and need urgently information.
Thanks.

Here is an short output with the results:

9997   385.42   68.54   9.82  124.09  23.93  138.24
9998   342.89   73.65 133.35 1134.19 345.99 1876.88
9999   316.23   76.35  48.26  421.70 129.80  873.79
10000  291.64  103.66   6.85  107.46  26.42  189.38
10001    0.00    0.00   0.00    0.00   0.00    0.00
 > mean(data)
       FSC       SSC       FL1       FL2      FL32       FL4
375.94880  73.76219  50.73413 434.42837 110.06393 637.34980
 > geo.mean(data)
[1] NaN
 > median(data)
Error in median(data) : need numeric data
 >




More information about the R-help mailing list