I am trying to recode the variable FamilyStatus in my dataframe na.df. The characters ("ledig", "verheiratet" and "sonstiges" should be recoded in numerics. I know, there are many similar questions and answers already but nothing fixed my problem, so I ask here. The same code structure works with other dataframes of mine. But what is wrong here?
this is my sample data:
head(na.df)
# A tibble: 6 x 5
StudyID Age FamilyStatus EducationalLevel CycleLength
<dbl> <dbl> <chr> <chr> <dbl>
1 1016 23 ledig Gymnasium 28
2 1007 28 ledig Gymnasium 30
3 1014 23 ledig Gymnasium 28
4 1006 21 ledig Gymnasium 28
5 1050 41 ledig Universität / Hochschule 27
6 1001 26 ledig Gymnasium 4
na.df.1 <- mutate(na.df,
FamilyStatus = recode(FamilyStatus,
"ledig"= '1',
"verheiratet" = '2',
"sonstiges" = '3'),
EducationalLevel = recode(EducationalLevel,
"Sekundar- / Realschule"= '1',
"Gymnasium" = '2',
"Universität / Hochschule" = '3'))
Fehler: Problem with `mutate()` input `FamilyStatus`.
x unbenutzte Argumente (ledig = "1", verheiratet = "2", sonstiges = "3")
ℹ Input `FamilyStatus` is `recode(FamilyStatus, ledig = "1", verheiratet = "2", sonstiges = "3")`.
Run `rlang::last_error()` to see where the error occurred.
Thanks for your help!