I am new to R and would like to understand how to use the if statement/if-else function to make distinctions between two options of a variable, which in my case would be gender. Specifically, i would like to use this dataset to see if there is a difference between men and women in having a bank account on their name(-1 and -2 are women and men, from 1:5 it's the options for the financial account). Next, i will create a chi squared table, but i would also find helpful any advice on how to show the direction of the data (so not only that there is a significance but that one gender has more bank accounts on their name than others ).
I am using other ways to make the gendered distinction, mostly by creating two datasets with subset or grepl like in the examples below but i am assuming there are easier ways.
RespSeason <-- data.frame(respjobhh, gendercleaned)
View(RespSeason)
RespseasonCleaned = na.omit(RespSeason)
View(RespseasonCleaned)
Seasonwoman <-- subset(RespseasonCleaned, gendercleaned == "-2")
Seasonmen<-- subset(RespseasonCleaned, gendercleaned == "-1")
gender = hh_complete_fixed_cleaned[,22 ]
gendercleaned = na.omit(gender)jobhh = hh_complete_fixed_cleaned[, 128]
jobhhcleaned = na.omit(jobhh)
sapply(jobhhcleaned, mean, na.rm = TRUE)
data.frame(jobhh, gendercleaned)
View(jobhh, gendercleaned)
genderjobbhh <-- data.frame(jobhh, gendercleaned)
View(genderjobbhh)
malehh <--genderjobbhh[!grepl('2', genderjobbhh$gendercleaned),]
View(malehh)
sapply(malehh, mean, na.rm = TRUE)
femalehh <--genderjobbhh[!grepl('1', genderjobbhh$gendercleaned),]
View(femalehh)
sapply(femalehh, mean, na.rm = TRUE)
Thank you in advance for your contribution
Aucun commentaire:
Enregistrer un commentaire