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

View source: R/isolate_sentinels.R

isolate_sentinelsR Documentation

Move sentinel values into a separate column leaving NA behind

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

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

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")

unpivotr documentation built on Jan. 23, 2023, 5:40 p.m.