Returns data object with NA values (if atomic vector), all NA elements (if list), or all NA rows (if data frame or matrix) omitted

na_omit(x)

Arguments

x

Data object

Value

Data with NA values (if atomic vector), all NA elements (if list), or all NA rows (if data frame or matrix) omitted.

Examples

## generate data df <- data.frame( a = I(list(c(1, 2), c(NA_integer_, NA_integer_), c(1, 2))), b = c("a", NA_character_, "c"), c = c(1.1243, NA_real_, -1.234134) ) ## data frame na_omit(df)
#> Warning: longer object length is not a multiple of shorter object length
#> Warning: longer object length is not a multiple of shorter object length
#> Warning: longer object length is not a multiple of shorter object length
#> a b c #> 1 1, 2 a 1.124300 #> 3 1, 2 c -1.234134
## matrix na_omit(as.matrix(df))
#> Warning: longer object length is not a multiple of shorter object length
#> Warning: longer object length is not a multiple of shorter object length
#> Warning: longer object length is not a multiple of shorter object length
#> a b c #> [1,] Numeric,2 "a" 1.1243 #> [2,] Numeric,2 "c" -1.234134
## list na_omit(apply(df, 1, c))
#> Warning: longer object length is not a multiple of shorter object length
#> Warning: longer object length is not a multiple of shorter object length
#> Warning: longer object length is not a multiple of shorter object length
#> [[1]] #> [[1]]$a #> [1] 1 2 #> #> [[1]]$b #> [1] "a" #> #> [[1]]$c #> [1] 1.1243 #> #> #> [[2]] #> [[2]]$a #> [1] 1 2 #> #> [[2]]$b #> [1] "c" #> #> [[2]]$c #> [1] -1.234134 #> #>
## atomic vector na_omit(df$b)
#> [1] a c #> Levels: a c