Re: [R] Error Calculating Mean

From: Mike Nielsen <mr.blacksheep_at_gmail.com>
Date: Mon 10 Jul 2006 - 05:45:22 EST

I'd hazard a guess that data.linear$Weight may have a "Not Available" data point (ie. missing data).

> f <- c(NA,rnorm(10))
> mode(f)

[1] "numeric"
> mean(f)

[1] NA

If you'd like to compute the mean anyway, you can use
> mean(f,na.rm=TRUE)

[1] 0.3433036

On 7/9/06, justin rapp <jdrapp@gmail.com> wrote:
> I have a vector containing players' weights. When I enter
>
>
> mode(data.linear$Weight)
> "numeric" is returned.
>
>
> When I type mean(data.linear$Weight)
>
> NA is returned.
>
> Any ideas as to why this may be the case? I am trying to calculate
> this ultimately so I can superimpose a normal density line over a
> histogram containing the weights?
>
> ______________________________________________
> 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
>

-- 
Regards,

Mike Nielsen

______________________________________________
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
Received on Mon Jul 10 05:48:17 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 10 Jul 2006 - 12:15:56 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.