Error: Problem with `mutate()` input `relig2`. x unused arguments

I am relatively new to R and currently doing an assignment where I have to run some models. I have some variables that I need to recode, but when running the code I get an error (see R code and error below). I use library(dplyr) to execute the command. I have also tried putting ticks around the numbers, inserting dplyr::recode and changed the order of the numbers, but still I get the same error. I feel like I have searched the entire internet for answers, but nothing has helped

mutate(relig2 = recode(rlgatnd,
                         "Every day" = 7,
                         "More than once a week" = 6,
                         "Once a week" = 5,
                         "At least once a month" = 4,
                         "Only on special holy days" = 3,
                         "Less often" = 2,
                         "Never" =  1,
                         "Refusal" = NULL,
                         "Don't know" = NULL,
                         "No answer" = NULL,
                         "NA's" = NULL))

Error: Problem with `mutate()` input `relig2`.
x unused arguments (`Every day` = 7, `More than once a week` = 6, `Once a week` = 5, `At least once a month` = 4, `Only on special holy days` = 3, `Less often` = 2, Never = 1, Refusal = NULL, `Don't know` = NULL, `No answer` = NULL, `NA's` = NULL)
ℹ Input `relig2` is `recode(...)`.
2. dplyr::mutate(...)
 15. dplyr:::h(simpleError(msg, call))

It's hard to pinpoint an error without a complete reprex. Generally, it's best to make variable names short; easier to type and avoids the backticks required for spaces. When it comes time for tabular presentation, after all the data manipulation has been done, it's simple to relabel the variables. Something along the following lines

the_data <- data.frame(
  daily = 7,
  once_plus_w = 6,
  once_w = 5,
  one_m = 4,
  holidays = 3,
  less_often = 2,
  never = 1,
  refusal = NA,
  dk = NA,
  no_ans = NA

#>   daily once_plus_w once_w one_m holidays less_often never refusal dk no_ans
#> 1     7           6      5     4        3          2     1      NA NA     NA

headers <- c(
  "More than once a week", "Once a week", "At least once a month", "Only on special holy days", "Less often", "Never",
  "Refusal", "Don't know", "No answer")

colnames(the_data) <- headers
Table continues below
More than once a week Once a week At least once a month
7 6 5

Table continues below

Table continues below
Only on special holy days Less often Never Refusal Don’t know
4 3 2 1 NA

Table continues below

No answer NA

Created on 2020-12-19 by the reprex package (v0.3.0.9001)

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.