Search code examples
rmean

The mean of a variable keeps coming back as NA


Hrstart <- c(MNC$hrstart)
Hrstart
mean(Hrstart) 
[1] NA

I wanted to get the mean of a variable (hrstart) but it keeps returning as NA.


Solution

  • There will be NA in your data. To get rid of them, use na.rm = TRUE:

    mean(Hrstart, na.rm = TRUE)