How do I recode a variable into yes and no in R studio?

Hello! So i'm trying to recode the following question:

During the past 7 days, on how many days have you snacked on junk food in your home?

1 0 days

2 1 to 2 days

3 3 to 4 days

4 5 to 6 days

5 7 days

I would like to change this to a yes/no question by setting those who answered 1 to be no and those who chose an answer choice that was >=2 to be yes. Thanks.

Try this:

mutate(result = ifelse(QUESTION > 1, 1, 0))

Chance yourdf and question according to your data

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.