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:

  1. 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
  1. Find the means and medians of avg_disgust by gender (i.e., for females and for males).

  2. Create a boxplot to compare avg_disgust across genders.

  3. Create a two-way frequency table with percentages by column (or row) for the variables perceived_discrim and gender. Then, create one for perceived_discrim and immstatus.

  4. Create bar charts that visualize the comparisons shown in both tables from the prior item.

  5. Run a regression with avg_disgust as the dependent variable and gender and immstatus as 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.


  1. 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)↩︎