remove_na | R Documentation |
Remove NAs from a vector
remove_na(x)
## Default S3 method:
remove_na(x)
## S3 method for class 'list'
remove_na(x)
## S3 method for class 'factor'
remove_na(x)
## S3 method for class 'fact'
remove_na(x)
x |
A vector of values |
remove_na.factor
will remove NA
values as identified by the levels()
or by the integer value of the level. factors
are recreated with all
NA
values and, if present, the NA
level
removed.
x
without values where is.na(x)
is TRUE
For factors, a new factor (ordered
if is.ordered(x)
)
remove_na(c(4, 1, 2, NA, 4, NA, 3, 2))
# removes based on levels
remove_na(fact(c("b", NA, "a", "c")))
# removes based on values
x <- as_ordered(c("b", "d", "a", "c"))
x[2:3] <- NA
str(remove_na(x))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.