recoding values using wildcard

19 Views Asked by At

I'm trying to recode values that have certain strings in common using a wildcard, if such a thing is possible.

data format is:

Name title
X1 Movie_1 X2 Book_1 X3 Book_2 X4 Movie_2

I want to recode: "_1" = "_1980s, "_2 = "_1990s"

I have tried: df %>% mutate(title=recode(tite,_1="_1980s",_2="_1990s"))

It runs without error message, but makes no substitutions. I assume because it is looking for a complete string called "_1" rather than part of a string.

I installed utils package and tried the same command with '*_1' but that didn't work, either.

0

There are 0 best solutions below