Isabella725 / stats_2_finalproject

Basic template for my research projects
MIT License
0 stars 0 forks source link

ISSUE #2

Closed Isabella725 closed 3 years ago

Isabella725 commented 5 years ago

hi @AaronGullickson I have two issues: okay first of all, I have realized that gender is coded into multiple columns because both face to face and web interviews were conducted. The FTF interviews also included a question on if any children under 18 were in the house. I think this variable may be the best one for me to operationalize fertility with. Therefore I wanted to just subset out my data and only include the FTF variables so I can figure out respondent's gender easily and maybe use this children under 18 variable.

In the code book it says, "The data can be analyzed using the combined dual-mode sample, or using the face-to-face sample alone, or using the Internet sample alone. In the combined sample, the larger number of Internet sample cases makes that mode dominate the estimates by a ratio of about 3:1. Analysis should be weighted to accurately represent the population. Sampling error calculations should account for the complex sample design and the effects of weighting on variance." So the data should be designed so that this is possible.

Okay so I tried to subset out using this code at the beginning of my analytical data(FTF is coded as 1 and web as 2): anes$ftf <- factor(ifelse(anes$v160501==1, NA, anes$V160501)) anes <- subset(anes, select=c ("ftf")) I get this warning: Unknown or uninitialised column: 'v160501'.

I got this same warning when I tried to create a variable for children under 18: anes$children <- factor(ifelse(anes$v165506<0, NA, anes$v165506), levels=c(2,1), labels=c("No","Yes"))

Let me know what I should do!

AaronGullickson commented 5 years ago

The immediate issue is that "v" needs to be "V" in your variable name. R is case-sensitive. The subset command is not quite right though, as the select argument is used to select specific variables not subset by observations. There is really no need to code the ftf variable at all. Just do this:

anes <- subset(anes, V160501==1)

If you fix the "v" issue, the code for the children variable works fine.