Created
September 20, 2012 15:54
-
-
Save evanemolo/3756749 to your computer and use it in GitHub Desktop.
Obese-discrimination-arrests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
snf <- read.csv("http://www.jakeporway.com/teaching/data/snf_2.csv", as.is=TRUE) | |
# First create a subset of the data only consisting of “good” weights and heights. | |
clean.subset = snf[snf$height > 40 & snf$weight > 90 & snf$weight < 400, ] | |
# Add a BMI variable to our dataset, where BMI is computed as (weight)*703/(height*height). | |
bmi = (clean.subset$weight)*703/(clean.subset$height*clean.subset$height) | |
# What percentage of people with BMI’s greater than or equal to 30 who were stopped were | |
# ultimately arrested? | |
obese.subset = clean.subset[bmi >= 30, ] | |
obese.arrested.subset = which(obese.subset$arrested == 1) | |
length(which(obese.subset$arrested == 1)) / nrow(obese.subset) | |
# Answer: | |
[1] 0.0777903 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment