Short question:
I can substitute certain variable values like this:
values <- c(\"a\", \"b\", \"a\", \"b\", \"c\", \"a\", \"b\") df <- data.frame(v
Your example is a bit unclear and not reproducible. However, based on guessing what you actually want, I could suggest trying this option using the data.table package:
df[values %in% c("a", "b"), values := "x"]
or the dplyr package:
df %>% mutate(values = ifelse(values %in% c("a","b"), x, values))