Learn R Programming

naaccr (version 3.1.1)

naaccr_factor: Replace NAACCR codes with understandable factors

Description

Replace NAACCR codes with understandable factors

Usage

naaccr_factor(x, field, keep_unknown = FALSE, ...)

Value

A factor vector version of x. The levels are short descriptions instead of the basic NAACCR codes. Codes which stood for "unknown" with no further information are replaced with NA.

If field names a text or site-specific field, x will be returned unchanged with a warning.

Arguments

x

Vector (usually character) of codes.

field

String giving the XML name of the NAACCR field to code.

keep_unknown

Logical indicating whether values of "unknown" should be a level in the factor or NA.

...

Additional arguments passed onto factor.

Examples

Run this code
  naaccr_factor(c("20", "43", "99"), "radRegionalRxModality")
  naaccr_factor(c("USA", "GER", "XEN"), "addrAtDxCountry")
  # Default: NA for unknowns,
  naaccr_factor(c("1", "8", "9"), "tumorGrowthPattern")
  naaccr_factor(c("1", "8", "9"), "tumorGrowthPattern", keep_unknown = TRUE)

Run the code above in your browser using DataLab