na.rm is similar to na.omit but allows to specify a list of variables to take into account.

na.rm(x, v = NULL)

Arguments

x

a data frame

v

a list of variables

Details

If v is not specified, the result of na.rm will be the same as na.omit. If a list of variables is specified through v, only observations with a missing value (NA) for one of the specified variables will be removed from x. See examples.

See also

Author

Joseph Larmarange <joseph@larmarange.net>

Examples

df <- data.frame(x = c(1, 2, 3), y = c(0, 10, NA), z = c("a", NA, "b"))
df
#>   x  y    z
#> 1 1  0    a
#> 2 2 10 <NA>
#> 3 3 NA    b
na.omit(df)
#>   x y z
#> 1 1 0 a
na.rm(df)
#>   x y z
#> 1 1 0 a
na.rm(df, c("x", "y"))
#>   x  y    z
#> 1 1  0    a
#> 2 2 10 <NA>
na.rm(df, "z")
#>   x  y z
#> 1 1  0 a
#> 3 3 NA b