na_assignments {mark} | R Documentation |
NA at positions
Description
Converts select elements of a vector into NA
s
This is how the end results are
-
NA_at
andNA_if
require a suitable index value (x[y] <- NA
)-
NA_at
expectsy
(or the result of functiony
) to beintegers
-
NA_if
expectsy
(or the result of functiony
) to belogical
-
-
NA_in
andNA_out
expect some values to match on-
NA_in
checksx[x %in% y] <- NA
-
NA_out
checksx[x %out% y] <- NA
(see match_ext)
-
Usage
NA_at(x, y, ...)
NA_if(x, y, ...)
NA_in(x, y, ...)
NA_out(x, y, ...)
Arguments
x |
A vector of values |
y |
Either a suitable value (see |
... |
Additional values passed to |
Details
Convert specific values to NA
Value
x
with assigned NA
values
See Also
Inspired by dplyr::na_if()
Examples
let <- ordered(letters[1:5])
NA_at(let, c(1, 3, 5)) # [1] <NA> b <NA> d <NA>
NA_if(let, let <= "b") # [1] <NA> <NA> c d e
NA_in(let, c("a", "c")) # [1] <NA> b <NA> d e
NA_out(let, c("a", "c")) # [1] a <NA> c <NA> <NA>
[Package mark version 0.8.0 Index]