unknown_to_na: Replace labels for unknown with NA

Description Usage Arguments Value Examples

View source: R/naaccr_factor.R

Description

Replace labels for unknown with NA

Usage

1
2
3
4
5
6
7
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

1
2
3
4
5
6
7
8
  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 Jan. 11, 2020, 9:17 a.m.