I have a dataframe called diary00 with multiple columns that starts with "act1". These columns contain numeric values.
I want to categorise these numeric values into 3 groups. Say, I want to classify 1,2,3,4 as leisure, 5,6,7 as work and 8,9,0 as home.
Is there a way for me to use either the function starts_with("act1") or "^act1" then convert the numeric values to character all at once?
I tried using the mutate() and recode() functions.
mutate(act1_001 = recode (act1_001, 1,2,3,4 = "leisure")
but an error returns:
Error: unexpected '=' in:
" mutate(act1_001 = recode(act1_001, 1,2,3,4 = "leisure")
cutorcase_whenstackoverflow.com/questions/39123458/…