isolate_sentinels: Move sentinel values into a separate column leaving NA behind

Description Usage Arguments Examples

View source: R/isolate_sentinels.R

Description

A sentinel value, takes the place of a value that isn't available for some reason. isolate_sentinels() removes these values from a column of data into a separate column, and optionally converts the data left behind into an appropriate data type.

Usage

1
isolate_sentinels(.data, col, sentinels, into = "sentinel")

Arguments

.data

A data frame.

col

The name of the column of data containing sentinel values.

sentinels

A vector of sentinel values to be removed.

into

A name to give the new column of sentinel values.

Examples

1
2
3
4
5
6
x <- data.frame(name = c("Matilda", "Nicholas", "Olivia", "Paul"),
                score = c(10, "confidential", "N/A", 12),
                stringsAsFactors = FALSE)
x
isolate_sentinels(x, score, c("confidential", "N/A"))
isolate_sentinels(x, score, c("confidential", "N/A"), "flag")

nacnudus/unpivotr documentation built on March 26, 2020, 2:39 a.m.