Description Usage Arguments Value See Also
A function to re-encode data by using a map. Patterns are accepted. unmentioned data are left intact.
Method for class data.frame supports a robust replacement for data by providing relevant map in the form of var = map.
1 2 3 4 5 6 7 8 9 10 | simple_recode(...)
## S3 method for class 'data.frame'
simple_recode(.data, ..., ignore.case = FALSE,
perl = TRUE)
## Default S3 method:
simple_recode(x, map, as = c("as_is", "numeric",
"factor", "character", "logical"), ignore.case = FALSE, perl = TRUE,
...)
|
... |
For data.frame: Replacement in the form of var = map. Maps must follow the syntax stipulated in the map parameter. For default method: Additional parameters passed to factor() |
.data |
A data frame to modify |
ignore.case, perl |
Parameters passed to gsub(). |
perl |
Are patterns follow the Perl-style regular expression. |
x |
a vector |
map |
A map. Map can be a list in the form of recoded_text = c(to_be_recoded_text) Or as a data frame having 2 columns named "from" and "to". |
as |
A character string defining the post-recoded data type of x. Default is keeping as-is. |
ignore.case |
Specify whether the pattern is case-insensitive. Default is FALSE (case sensitive) |
A data frame with recoded variables.
If input is a vector, return a vector of the same length.
If input is a data frame, return a data frame with relevant variables recoded.
regex case_when
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.