Put it into Practice
Now it’s time to try things out for yourself. Complete each of the following steps, based on what we learned in this chapter.
Unless your instructor tells you otherwise, use an R script to execute all code needed to accomplish the following:
- Load in the Vulnerable Neighborhoods Survey dataset (
vns.dta).1 You can download it here and save it on your computer. Or you can load the file directly into R through the Internet with the following URL: https://learndata.net/vns.dta
Find the means and medians of
avg_disgustbygender(i.e., for females and for males).Create a boxplot to compare
avg_disgustacross genders.Create a two-way frequency table with percentages by column (or row) for the variables
perceived_discrimandgender. Then, create one forperceived_discrimandimmstatus.Create bar charts that visualize the comparisons shown in both tables from the prior item.
Run a regression with
avg_disgustas the dependent variable andgenderandimmstatusas independent variables. Make sure both independent variables are treated as factor (qualitative) variables.
After completing all of this, you should save your R script in a folder that is convenient to access. If you are submitting work to an instructor, they will likely want you to send them both your R script and a Word doc containing your results.
This is a modified version of data obtained from Sønderskov and colleagues: https://doi.org/10.17605/OSF.IO/62BV5 (CC-BY 4.0)↩︎