powered by
Recode specified values by new values
re_code(x, from, to)
A vector, including column of data frame
The set of old values to be replaced by new ones
The set of new values to replace the old ones
A vector that is the input vector but with old values replaced by new ones.
# NOT RUN { # Replace any occurrence of 1 and 2 with 101 and 201, respectively x <- c(1, 2, 3, 4, 5, 1, 2) re_code(x, from = c(1, 2), to = c(101, 201)) # }
Run the code above in your browser using DataLab