unknown_to_na {naaccr} | R Documentation |
Replace labels for unknown with NA
Description
Replace labels for unknown with NA
Usage
unknown_to_na(x, ...)
## S3 method for class 'naaccr_record'
unknown_to_na(x, ...)
## S3 method for class 'factor'
unknown_to_na(x, field, ...)
Arguments
x |
Either a factor created with |
... |
Further arguments passed to or from other methods. |
field |
String giving the XML name of the NAACCR field to code. |
Value
If x
was a factor
, then the result is a vector with the
values of x
, except all levels which effectively mean "unknown" are
replaced with NA
.
The returned factor won't have those in its levels, either.
If x
is a naaccr_record
object, then the result is the
naaccr_record
created by applying this function to all columns of
x
.
Examples
r <- naaccr_record(
sex = c("1", "2", "9"),
kras = c("8", "9", "3"),
keep_unknown = TRUE
)
r
unknown_to_na(r[["sex"]], field = "sex")
unknown_to_na(r)
[Package naaccr version 2.0.2 Index]