replace_pattern {thinkr} | R Documentation |
Replace pattern everywhere in a data.frame
Description
Replace pattern everywhere in a data.frame
Usage
replace_pattern(dataset, pattern, replacement, exact = FALSE)
Arguments
dataset |
a data.frame |
pattern |
Pattern to look for. |
replacement |
A character of replacements. |
exact |
a boolean if TRUE the whole value need ton match |
Value
a data.frame
Examples
dataset <- data.frame(
col_a = as.factor(letters)[1:7],
col_b = letters[1:7],
col_c = 1:7,
col_d = paste0(letters[1:7], letters[1:7]),
stringsAsFactors = FALSE
)
# replace pattern
replace_pattern(dataset, "a", "XXX-")
# With exact matching
replace_pattern(dataset, "a", "XXX-", exact = TRUE)
[Package thinkr version 0.16 Index]