Seeking help for using filter and mutate command to break down a current variable into separate variables

Hi Allen, I would say that the first step you need to try to do is to put your data into reprex (reproducible example).

Another thing I would suggest that you shouldn't use group_by before you use mutate to create new columns.

Also, take a look at dplyr::case_when function. It'll probably be easier than what you are doing now with mutate.

Finally, you should try to isolate your error to as small of subset of variables as possible. For example, right now you use select to choose multiple columns and then you use mutate to create a column with multiple states. Will this error appear when you use just, e.g., 2 columns in select and only one state in mutate? If yes, then it'll be easier to troubleshoot what is going wrong.

1 Like