unknown_to_na: Replace labels for unknown with NA

View source: R/naaccr_factor.R

unknown_to_naR 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 naaccr_factor, or a naaccr_record object.

...

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)

naaccr documentation built on Nov. 23, 2022, 5:06 p.m.