View source: R/naaccr_factor.R
split_sentineled | R Documentation |
Separate a sentineled field's values into two vectors: one with the continuous data and one with the sentinel values.
split_sentineled(x, field)
x |
Vector (usually character) of codes. |
field |
String giving the XML name of the NAACCR field to code. |
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.
node_codes <- c("10", "20", "90", "95", "99", NA)
s <- split_sentineled(node_codes, "regionalNodesPositive")
print(s)
s[is.na(s[["regionalNodesPositive"]]), "regionalNodesPositiveFlag"]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.