[R] Error Calculating Mean

Mike Nielsen mr.blacksheep at gmail.com
Sun Jul 9 21:45:22 CEST 2006


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



More information about the R-help mailing list