R/isolate_sentinels.R
isolate_sentinels.Rd
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.
isolate_sentinels(.data, col, sentinels, into = "sentinel")
.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. |
x <- data.frame(name = c("Matilda", "Nicholas", "Olivia", "Paul"), score = c(10, "confidential", "N/A", 12), stringsAsFactors = FALSE) x#> name score #> 1 Matilda 10 #> 2 Nicholas confidential #> 3 Olivia N/A #> 4 Paul 12#> name score sentinel #> 1 Matilda 10 <NA> #> 2 Nicholas <NA> confidential #> 3 Olivia <NA> N/A #> 4 Paul 12 <NA>#> name score flag #> 1 Matilda 10 <NA> #> 2 Nicholas <NA> confidential #> 3 Olivia <NA> N/A #> 4 Paul 12 <NA>