split_sentineled: Separate a field's continuous and sentinel values

View source: R/naaccr_factor.R

split_sentineledR Documentation

Separate a field's continuous and sentinel values

Description

Separate a sentineled field's values into two vectors: one with the continuous data and one with the sentinel values.

Usage

split_sentineled(x, field)

Arguments

x

Vector (usually character) of codes.

field

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

Value

If field is a sentineled field, a data.frame with two columns. The first is a numeric version of the continuous values from x. Its name is the value of field. The second is a factor with levels representing the sentinel values. For all non-missing values in the numeric vector, the respective value in the factor is NA. If a value of x was not valid, the respective row will be NA for the continuous and flag values.

If field is not a sentineled field, a data.frame with just x is returned with a warning.

Examples

  node_codes <- c("10", "20", "90", "95", "99", NA)
  s <- split_sentineled(node_codes, "regionalNodesPositive")
  print(s)
  s[is.na(s[["regionalNodesPositive"]]), "regionalNodesPositiveFlag"]

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