| data the data frame | R Documentation |
Replace all occurrences of given values in all columns of a data frame.
The data data frame contains a collection of records, with attributes organized in columns. It may include various types of values, such as numerical, categorical, or textual data.
replace_values(data, to_replace, replace_with)
data |
The input data frame to be modified. |
to_replace |
A vector of values to be replaced within the data frame. This must be the same length as |
replace_with |
A vector of corresponding replacement values. This must be the same length as |
Modified data frame with specified values replaced.
data <- data.frame(
q1 = c("neg2", "neg1", "0"),
q2 = c("1", "neg2", "neg1")
)
replace_values(
data,
to_replace = c("neg2", "neg1"),
replace_with = c("-2", "-1")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.