I'm trying to create a binary variable as answer to another binary variable
This is the gpa2 dataset from wooldridge library. I tried to create the variable male with a while loop too but it still doesn't work. I've already tried adding else statements but it didn't work.
`library(wooldridge)
gpa2 <- gpa2
for(i in 1:length(gpa2$female)){
if(gpa2$female == 0 ){
gpa2$male = 1
}
}`
I expect male be 0 when female is 1 and male be 1 when female is 0, but the output I get is male = 0 for every observation.
Aucun commentaire:
Enregistrer un commentaire