library(ggplot2)
library(dplyr)
# Prettier graphs
theme_set(theme_bw())
This question is Question 4.2 from the textbook and has been reproduced here along with R code to create the table. Use R and the appropriate functions from the table lab for your answers.
Nine-hundred and ten (910) randomly sampled registered voters from Tampa, FL were asked if they thought workers who have illegally entered the US should be (i) allowed to keep their jobs and apply for US citizenship, (ii) allowed to keep their jobs as temporary guest workers but not allowed to apply for US citizenship, or (iii) lose their jobs and have to leave the country. The results of the survey by political ideology are shown below.
## Copy and run this code to create table
tab <- structure(c(57L, 121L, 179L, 15L, 101L, 28L, 45L, 1L, 120L, 113L,
126L, 4L), dim = 4:3, dimnames = list(response = c("Apply for citizenship",
"Guest worker", "Leave the country", "Not sure"), political = c("conservative",
"liberal", "moderate")), class = "table")
tab
## political
## response conservative liberal moderate
## Apply for citizenship 57 101 120
## Guest worker 121 28 113
## Leave the country 179 45 126
## Not sure 15 1 4
What percent of these Tampa, FL voters identify themselves as conservatives?
What percent of these Tampa, FL voters are in favor of the citizenship option?
What percent of these Tampa, FL voters identify themselves as conservatives and are in favor of the citizenship option?
What percent of these Tampa, FL voters who identify themselves as conservatives are also in favor of the citizenship option? What percent of moderates share this view? What percent of liberals share this view?
Do political ideology and views on immigration appear to be associated? Explain your reasoning.
This question uses police shooting data aggregated by the Washington Post documenting all fatal shootings by a police officer between 2015-2022.
A dictionary of terms used can be found here
# Copy and paste these lines to load data
police <- read.csv("https://remiller1450.github.io/data/Police.csv")
# Clean data for problem by selecting relevant
# columns and removing missing values
police <- police[, c(3,4,5,6,9,10,11,12,13,17)]
police <- police[complete.cases(police) &
police$flee != "" &
police$gender != "", ]
Which five states had the greatest number of shootings between 2015-2022?
Below is a plot demonstrating the relationship between whether or not a body camera was being used during the shooting and whether the assailant was either shot or both shot and tasered. Create the table associated with this plot, find the odds of being shot vs shot and tasered and determine from the ratio of these odds whether or not the two variables appear to be associated.
shot | shot and Tasered | |
---|---|---|
attack | 0.65366 | 0.49191 |
other | 0.32165 | 0.49515 |
undetermined | 0.02469 | 0.01294 |