I've searched several help-pages and already answered questions but still get an error message when I try to recode multiple columns.
Example dataset:
test <- tibble (
a_test = c(7,6,5,4),
b_test = c(7,7,5,3),
c_test = c(7,3,7,5),
d_test = c(7,7,7,7)
)
test %>%
mutate(across(vars(contains('test')), recode, "1" = "7", "2" = "6", "3" = "5", "4" = "4", "5" = "3", "6" = "2", "7" = "1")
Once I run this code, I get the following error message:
Error in mutate()
:
! Problem while computing ..1 = across(...)
.
Caused by error in across()
:
! Must subset columns with a valid subscript vector.
x Subscript has the wrong type quosures
.
i It must be numeric or character.
I'd really appreciate your help. Thanks in advance!