Error code with mutate/recode

I have been trying to do some data wrangling (specifically mutating and recoding) with two different datasets and I keep getting this response about replacement has X rows, data has X. I cannot for the life of me figure out why this is.

"Error in $<-.data.frame(*tmp*, "call_text", value = c("... %>% tidyr::drop_na(regtype, happy)", : replacement has 5 rows, data has 4"
OR
"Error in mutate(): ! Problem while computing ..1 = recode(importance, very = 4, somewhat = 3, notvery = 2, not = 1). Caused by error in recode(): ! unused arguments (very = 4, somewhat = 3, notvery = 2, not = 1) Backtrace: 1. ces_new %>% ... 3. dplyr:::mutate.data.frame(., recode(importance, very = 4, somewhat = 3, notvery = 2, not = 1)) 4. dplyr:::mutate_cols(.data, dplyr_quosures(...), caller_env = caller_env()) 6. mask$eval_all_mutate(quo)

Error in mutate(., recode(importance, very = 4, somewhat = 3, notvery = 2, : Caused by error in recode(): ! unused arguments (very = 4, somewhat = 3, notvery = 2, not = 1)"

Has anyone experienced this before? Is it to do with the class of the variable (they are factors)?

See the FAQ on reprex for how to show problem code in a way that is more likely to produce more useful answers.

If two data frames have differing numbers of rows, operations that attempt to combine them column-wise will fail with this message. Filling out the shorter with a row of NAs beforehand may help.

thanks for the response, I'm new to R so when you say "See the FAQ on reprex", is this an area in R? how do I access it?

You can search for how to do a reprex on this forum. For example:

FAQ: How to do a minimal reproducible example ( reprex ) for beginners - meta / Guides & FAQs - RStudio Community

1 Like

This topic was automatically closed 21 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.