H B
H B

Reputation: 1

na.rm is not found in R

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

Upvotes: -1

Views: 1559

Answers (1)

Afshin
Afshin

Reputation: 133

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.

Upvotes: 2

Related Questions