library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(janitor)
##
## Attaching package: 'janitor'
## The following objects are masked from 'package:stats':
##
## chisq.test, fisher.test
library(haven)
library(haven)
anes2020<-read_dta("C:\\Users\\USER\\Downloads\\anes2020.dta")
anes2020$V201018[anes2020$V201018 <0] <- NA
anes2020$V202491[anes2020$V202491 <0] <- NA
anes2020 %>%
tabyl(V201018 )
## V201018 n percent valid_percent
## 1 1861 0.224758454 0.436957032
## 2 1336 0.161352657 0.313688659
## 4 1029 0.124275362 0.241606011
## 5 33 0.003985507 0.007748298
## NA 4021 0.485628019 NA
anes2020 %>%
tabyl(V201018,V202491,show_missing_levels=F,show_na = FALSE) %>%
adorn_percentages("row") %>%
adorn_pct_formatting(digits=2) %>%
adorn_ns() %>%
knitr::kable()
| 1 |
85.65% (1427) |
13.69% (228) |
0.66% (11) |
| 2 |
37.37% (435) |
60.82% (708) |
1.80% (21) |
| 4 |
64.47% (586) |
34.10% (310) |
1.43% (13) |
| 5 |
63.33% (19) |
33.33% (10) |
3.33% (1) |
| According to the table 85.65% of people who vote for the democratic party feel that police treat whites better than blacks. Less that 1% (.66%) feel that blacks are treated better than whites and vote Democratic. 1.80% (21) of People who vote Republican feel that blacks are treated better, where as a majority (60.82%) feel that both blacks and whites are treated the same by police. A majority of independent voters (64.47%) feel that whites are treated better, where as 34.10% feel that whites and blacks are treated the same during police encounters. A majority of voters who identify as other feel that police officers treat whites better than their black counterparts during interactions as seen on row 1. |
| The democratic row has the largest number of participants, at 1,666 versus the 1,164 people who identify as Republican. The table also shoes that Republicans also have the largest number (708) of people who feel that both blacks and whites are treated equally during police encounters. |
| In this table I used Party of Registration (V201018) explain the a persons views on treatment of police officers towards Black and White Americans (V202491). The table shows that there is a strong association between a persons registered party and feelings about treatment of police officers. People who register as Democratic, overwhelmingly, feel that an interaction on the streets between a black and police officer will be more negative. On the other hand, people who register as Republicans strongly feel that a Black person will be treated the same as a White person on the street. |