remove_na {mark} | R Documentation |
Remove NA
Description
Remove NAs from a vector
Usage
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)
Arguments
x |
A vector of values |
Details
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.
Value
x
without values where is.na(x)
is TRUE
For factors, a new factor (ordered
if is.ordered(x)
)
Examples
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))
[Package mark version 0.8.0 Index]