Error message mutate function

Hello!

i've been trying to recode my data with the mutate function:
data <- data %>%
mutate(y = recode(QUESTNNR,
SQ_EN_2016 = “SQ”)

After I tried to run this command, the following error message appeared:
Error: Problem with ’mutate () ' column ’y'.
i ’y = recode (. . . ) '.
x unused arguments (SQ_EN_2016 = “SQ”)
Backtrace:

  1. data %>% mutated (y = recode (QUESTNNR, SQ_FR_2016 = “SQ”))
  2. base::. handleSimpleError (. . . )
  3. dplyr:::h (simpleError (msg, call))

In contrast, the command went through normally yesterday, which is no longer the case.
Since I haven't changed the command in the meantime, I wanted to ask what the source of the error could be.

Thanks a lot for your help!

Try :

SQ_EN_2016 == “SQ”

that is, two equal signs.

Unfortunatly that hadn't had an impact.
Now the error message would be:
Error: Problem with mutate() column y.
i y = recode(QUESTNNR,SQ_FR_2016 == “SQ”").
x object 'SQ_FR_2016 ' not found
Backtrace:

  1. %>%(...)
  2. base::.handleSimpleError(...)
  3. dplyr:::h(simpleError(msg, call))

Can you provide some minimally working example of your data and an explanation of what you are trying to achieve?

I tried piecing together some mock data based on your question and tried recoding the relevant variable, see below:

library(tidyverse)

data <- tibble::tibble(QUESTNNR = sample(c("SQ_FR_2016", "SQ_EN_2016"), 10, replace = TRUE))

data
#> # A tibble: 10 × 1
#>    QUESTNNR  
#>    <chr>     
#>  1 SQ_EN_2016
#>  2 SQ_EN_2016
#>  3 SQ_EN_2016
#>  4 SQ_FR_2016
#>  5 SQ_FR_2016
#>  6 SQ_FR_2016
#>  7 SQ_EN_2016
#>  8 SQ_EN_2016
#>  9 SQ_FR_2016
#> 10 SQ_FR_2016

data %>% 
  mutate(y = recode(QUESTNNR, "SQ_FR_2016" = "SQ"))
#> # A tibble: 10 × 2
#>    QUESTNNR   y         
#>    <chr>      <chr>     
#>  1 SQ_EN_2016 SQ_EN_2016
#>  2 SQ_EN_2016 SQ_EN_2016
#>  3 SQ_EN_2016 SQ_EN_2016
#>  4 SQ_FR_2016 SQ        
#>  5 SQ_FR_2016 SQ        
#>  6 SQ_FR_2016 SQ        
#>  7 SQ_EN_2016 SQ_EN_2016
#>  8 SQ_EN_2016 SQ_EN_2016
#>  9 SQ_FR_2016 SQ        
#> 10 SQ_FR_2016 SQ

Created on 2022-01-04 by the reprex package (v2.0.1)

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.