I'm trying to create new dummy variable ps2female
(0=male, 1=female) by using information from existing variable bysex
(1=male, 2=female), but keep gets an error.
#Loading Data (data to R)
library(tidyverse)
library(haven)
els02 <- read_dta(file="els02_processed_small.dta")
els02$bysex
value label
<fctr> <fctr>
-8 Survey component legitimate skip/NA
-4 Nonrespondent
1 Male
2 Female
4 rows
library(dplyr)
els02 %>%
mutate(ps2female = recode(bysex, "1" = "0", "2" = "1"))
Error in recode(bysex, `1` = "0", `2` = "1") : unused arguments (`1` = "0", `2` = "1")
Any suggestions? Thanks in advance.