[R] Problem with Median

Sarah Goslee sarah.goslee at gmail.com
Mon May 7 20:55:24 CEST 2012


Please use dput() to give us your data (eg dput(data) ) rather than
simply pasting it in.

Sarah

On Mon, May 7, 2012 at 2:52 PM, Suhaila Haji Mohd Hussin
<bell_beauty12 at hotmail.com> wrote:
>
> Hello.
> I'm trying to compute median for a filtered column based on other column but there was something wrong. I'll show how I did step by step.
> Here's the data:
>     a     b     c      class
>
> 1   12   0      90     A-B2   3     97    11     A-B3   78   NA    123   A-C4   NA   NA    12    A-C5   8     33     2     A-B6   12   NA     0     A-D
> On the command I typed:
> 1) data = read.csv("data.csv")
>
> 2) a.AC <- subset(data, class == "A-C", select = a)
> 3) median(a.AC)Error in median.default(a.AC) : need numeric data
> 4) is.numeric(a.AC)FALSE
> 5) as.numeric(a.AC)Error: (list) object cannot be coerced to type 'double'
> How can I fix this? Please help.
> Cheers,Suhaila


-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list