I am trying to aggrupate the categories of my variables. For some reason the function rather gives error:
Error in `mutate()`:
ℹ In argument: `across(...)`.
Caused by error in `across()`:
ℹ In argument: `all_of(Nivell_Educatiu_Mare)`.
Caused by error:
! objeto 'Nivell_Educatiu_Mare' no encontrado
Run `rlang::last_trace()` to see where the error occurred.
Rather doesn't read it as a function:
> dadespares_netes <- dadespares_netes %>%
+ Nivell_Educatiu_Pare == "No sap llegir ni escriure" ~ "Primària incompleta",
Error: inesperado ',' in:
"dadespares_netes <- dadespares_netes %>%
Nivell_Educatiu_Pare == "No sap llegir ni escriure" ~ "Primària incompleta","
> Nivell_Educatiu_Pare == "Primera etapa de secundària" ~ "ESO",
Error: inesperado ',' en " Nivell_Educatiu_Pare == "Primera etapa de secundària" ~ "ESO","
> Nivell_Educatiu_Pare == "Universitaris de grau superior" ~ "Universitaris",
Error: inesperado ',' en " Nivell_Educatiu_Pare == "Universitaris de grau superior" ~ "Universitaris","
> TRUE ~ Nivell_Educatiu_Pare # retain original value if no match
The code was working before, I used it in another project, and I actually changed some category names in this project with the same codes. All of a sudden, it stopped working.
The data frame is loaded and read, dplyr too, the names of the variables and categories are correct too...
I have been trying to solve it for already an hour, and not even reestarting the program and the computer I made it work. I tried with recode, and case when()
The code above doesn't make sense to me. You are passing dadespares_netes into Nivell_Educatiu_Pare but Nivell_Educatiu_Pare isn't a function. Simultaneously, you are setting up a bare formula with Nivell_Educatiu_Pare == "No sap llegir ni escriure" ~ "Primària incompleta". Pleases show . Please show more of your code, not just the parts that throw an error.
The unexpected comma error in your second code chunk is because the pipe operator is expecting a function (into whose first argument dadespares_netes will be substituted) but instead finding a logic expression (Nivell_Educatiu_Pare is equal to "No sap llegir ni escriure" ~ "Primària incompleta"). It is not clear what part of your code is supposed to be a function.