remove NA values
Usage
rmNA(
x,
naValue = NULL,
rmNULL = FALSE,
nullValue = naValue,
rmInfinite = TRUE,
infiniteValue = NULL,
rmNAnames = FALSE,
verbose = FALSE,
...
)
Arguments
- x
vector input
NULL or single replacement value for NA entries. If NULL, then NA entries are removed from the result.
- rmNULL
logical
whether to replace NULL entries withnullValue
- nullValue
NULL or single replacement value for NULL entries. If NULL, then NULL entries are removed from the result.
- rmInfinite
logical
whether to replace Infinite values with infiniteValue- infiniteValue
value to use when rmInfinite==TRUE to replace entries which are Inf or -Inf.
- rmNAnames
logical
whether to remove entries which have NA as the name, regardless whether the entry itself is NA.- verbose
logical
whether to print verbose output- ...
additional arguments are ignored.
Value
vector with NA entries either removed, or replaced with naValue, and NULL entries either removed or replaced by nullValue.
Details
This function removes NA values, by default shortening a vector as a result, but optionally replacing NA and Infinite values with fixed values.
See also
Other jam practical functions:
breakDensity()
,
call_fn_ellipsis()
,
checkLightMode()
,
check_pkg_installed()
,
colNum2excelName()
,
color_dither()
,
exp2signed()
,
getAxisLabel()
,
isFALSEV()
,
isTRUEV()
,
jargs()
,
kable_coloring()
,
lldf()
,
log2signed()
,
middle()
,
minorLogTicks()
,
newestFile()
,
printDebug()
,
reload_rmarkdown_cache()
,
renameColumn()
,
rmInfinite()
,
rmNAs()
,
rmNULL()
,
setPrompt()
Examples
# by default it removes NA, shortening the vector
rmNA(c(1, 5, 4, NA, 10, NA))
#> [1] 1 5 4 10
# convenient to replace NA with a fixed value
rmNA(c(1, 5, 4, NA, 10, NA), naValue=0)
#> [1] 1 5 4 0 10 0
m <- matrix(ncol=3, 1:9)
m[1, 2] <- NA;
rmNA(m, naValue=-1)
#> [,1] [,2] [,3]
#> [1,] 1 -1 7
#> [2,] 2 5 8
#> [3,] 3 6 9
# by default NA and Inf is removed
rmNA(c(1, 5, 4, NA, 10, NA, Inf, -Inf))
#> [1] 1 5 4 10
# NA and Inf can be replaced, note Inf retains the sign
rmNA(c(1, 5, 4, NA, 10, NA, Inf, -Inf), naValue=0, infiniteValue=100)
#> [1] 1 5 4 0 10 0 100 -100