-1

I am trying to use na.rm but it looks like it is not in R at all. I was using it in the past just now it does not seem to be there at all. I tried using the help() function and the ??na.rm both showed not results. How could this suddenly happen? and how do I get it back?

thank you

1

2

camille
  • 16,432
  • 18
  • 38
  • 60
H B
  • 1
  • 4

1 Answers1

1

Actually na.rm is not a function for you to call. It is an argument that is used inside some built-in functions such as mean(), sd(), var() etc. If you want to remove missing (NA values) from a data set (vector, matrix, data frame, tibble etc.) you may use na.omit for it is a base function. See the example below:

x <- c(2, 3, 5, NA, 5, NA)
mean(x, na.rm=TRUE)
[1] 3.75

As you can see, the mean of x vector is calculated excluding the missing values.

Afshin
  • 103
  • 6