Skip to content

Commit 946427b

Browse files
technical file update
1 parent f053b49 commit 946427b

4 files changed

Lines changed: 1378 additions & 152 deletions

File tree

reports/data-wells.Rmd

Lines changed: 101 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
---
2-
title: "*Data Wells* in the Campaigns on State Violence (Draft)"
3-
author: "Quantitative Histories Workshop"
2+
title: "Data Wells: Technical file"
3+
author:
4+
- "Nathan Alexander, Kade Davis"
5+
- "Quantitative Histories Workshop"
46
output:
57
html_document:
68
toc: true
79
toc_depth: 2
10+
toc_float: true # Enable floating TOC in the sidebar
811
number_sections: true
9-
theme: flatly
12+
theme: cerulean
1013
editor_options:
1114
markdown:
1215
wrap: sentence
@@ -17,26 +20,80 @@ knitr::opts_chunk$set(echo = TRUE)
1720
library(tidyverse)
1821
library(dplyr)
1922
library(tidyr)
23+
library(readr)
2024
library(here)
2125
here::i_am("data-wells.Rmd")
2226
```
2327

24-
## Overview
25-
28+
# Overview
29+
30+
We provide here the technical code and methods to accompany our analysis of data on lynching and policing. We examine some of the historical and contemporary contexts of state violence and social control using a game theoretic analysis regarding the state's means of production towards social control -- we then situate this idea using Goodwin's (1992) analysis around *professional visions* and we broadly frame our analysis within the research in Black and African American studies. We also consider some of the structures, assumptions, and quantitative models related to the analysis of the historical data. We make use of original source data from Ida B. Wells-Barnett's *The Red Record* and the Washington Post *Fatal Force* database.
31+
32+
# Data
33+
34+
## The Washington Post Fatal Force database
35+
2636
```{r}
2737
# fatal database
28-
df <- read.csv("https://raw.githubusercontent.com/washingtonpost/data-police-shootings/refs/heads/master/v2/fatal-police-shootings-data.csv")
29-
str(df)
38+
fatal <- read.csv("https://raw.githubusercontent.com/washingtonpost/data-police-shootings/refs/heads/master/v2/fatal-police-shootings-data.csv")
39+
str(fatal)
40+
```
41+
42+
```{r}
3043
# fix vars
3144
# change vars to more appropriate formats
32-
df$date <- as.Date(df$date) # check/change to date format
33-
df$age <- as.numeric(df$age)
34-
df$was_mental_illness_related <- as.logical(df$was_mental_illness_related)
35-
df$body_camera <- as.logical(df$body_camera)
36-
str(df)
45+
fatal$date <- as.Date(fatal$date) # check/change to date format
46+
47+
fatal$age <- as.numeric(fatal$age)
48+
49+
fatal$gender[fatal$gender == ""] <- NA
50+
fatal$gender <- as.factor(fatal$gender)
51+
fatal$gender <- droplevels(fatal$gender)
52+
53+
fatal <- fatal %>%
54+
mutate(
55+
race_category = case_when(
56+
race == "" ~ NA_character_,
57+
race == "A" ~ "Asian",
58+
race == "B" ~ "Black",
59+
race == "H" ~ "Hispanic",
60+
race == "N" ~ "Native American",
61+
race == "O" ~ "Other",
62+
race == "W" ~ "White",
63+
race == "B;H" ~ "Black, Hispanic",
64+
race == "N;H" ~ "Native, Hispanic",
65+
race == "W;A" ~ "White, Asian",
66+
race == "W;B" ~ "White, Black",
67+
race == "W;B;N" ~ "White, Black, Native",
68+
race == "W;H" ~ "White, Hispanic",
69+
TRUE ~ "Other"
70+
)
71+
)
72+
fatal$race_category <- as.factor(fatal$race_category)
73+
74+
library(dplyr)
75+
76+
fatal <- fatal %>%
77+
mutate(
78+
black = case_when(
79+
race == "B" ~ "Black",
80+
grepl(";", race) & grepl("B", race) ~ "Black Other", # Multiracial with Black
81+
TRUE ~ "Non-Black"
82+
)
83+
)
84+
85+
# convert to factor for ordered levels
86+
fatal$black <- factor(fatal$black,
87+
levels = c("Black", "Black Other", "Non-Black"))
88+
89+
fatal$was_mental_illness_related <- as.logical(fatal$was_mental_illness_related)
90+
91+
fatal$body_camera <- as.logical(fatal$body_camera)
92+
93+
str(fatal)
3794
3895
# view a summary of the data
39-
summary(df)
96+
summary(fatal)
4097
4198
# create a two-column transfer df to match state to abb
4299
transfer <- tibble(state = state.name) %>%
@@ -46,36 +103,52 @@ transfer
46103
tail(transfer)
47104
48105
# add a state name variable to the fatal df
49-
df$state.name <- state.name[match(df$state, transfer$abb)]
50-
df %>%
106+
fatal$state.name <- state.name[match(fatal$state, transfer$abb)]
107+
fatal %>%
51108
mutate(state.abb = state) %>%
52-
relocate(id, date, state.name, state.abb) -> df
109+
relocate(id, date, state.name, state.abb) -> fatal
53110
54111
# create a year column
55112
# format to 20YY
56-
df.year <- format(df$date, format="20%y")
57-
df$year <- df.year # add column to df
58-
df$year <- as.numeric(df$year)
59-
df %>% relocate(id, date, year, state.name, state.abb) -> df
60-
tail(df)
113+
fatal.year <- format(fatal$date, format="20%y")
114+
fatal$year <- fatal.year # add column to df
115+
fatal$year <- as.numeric(fatal$year)
116+
fatal %>% relocate(id, date, year, state.name, state.abb) -> fatal
117+
tail(fatal)
61118
```
62119

63-
```{r}
64-
df1893 <- read.csv("https://raw.githubusercontent.com/quant-shop/IdaBWellsProject/master/RedRecord/redrecord1893.csv")
65-
66-
df1894 <- read.csv("https://raw.githubusercontent.com/quant-shop/IdaBWellsProject/master/RedRecord/redrecord1894.csv")
120+
Subsetting data for 2023 and 2024.
67121

68-
df2023 <- df %>%
122+
```{r}
123+
df2023 <- fatal %>%
69124
filter(year == 2023)
70125
71-
df2024 <- df %>%
126+
df2024 <- fatal %>%
72127
filter(year == 2024)
73128
```
74129

130+
## Ida B. Wells-Barnett's The Red Record data
131+
132+
We then load data from The Red Record. Data are gathered from two sources. We conduct a set of cross references to confirm the final selection of case studies for the analysis.
133+
134+
```{r}
135+
# data from forked repo on IdaBWellsProject
136+
df1893 <- read.csv("https://raw.githubusercontent.com/quant-shop/IdaBWellsProject/master/RedRecord/redrecord1893.csv")
137+
138+
df1894 <- read.csv("https://raw.githubusercontent.com/quant-shop/IdaBWellsProject/master/RedRecord/redrecord1894.csv")
139+
```
140+
75141
```{r}
76-
str(df2024)
142+
# records from quant shop entry
143+
df1892 <- read_csv("../data/Red Record Lynching Record - 1892.csv")
144+
145+
df1893b <- read_csv("../data/Red Record Lynching Record - 1893.csv")
146+
147+
df1894b <- read_csv("../data/Red Record Lynching Record - 1893.csv")
77148
```
78149

150+
## Standardizing data frames
151+
79152
```{r}
80153
# standardize data frames
81154
# --- Fix date columns for 1893 and 1894 ---
@@ -111,20 +184,9 @@ missing_cols <- setdiff(names(df2023), names(df1894))
111184
for(col in missing_cols) df1894[[col]] <- NA
112185
df1894 <- df1894[, names(df2023)]
113186
114-
# --- Combine all data frames (if desired) ---
115187
all_years <- rbind(df1893, df1894, df2023, df2024)
116188
```
117189

118-
```{r}
119-
library(readr)
120-
df1893b <- read_csv("../data/Red Record Lynching Record - 1893.csv")
121-
122-
df1892 <- read_csv("../data/Red Record Lynching Record - 1893.csv")
123-
124-
df1894b <- read_csv("../data/Red Record Lynching Record - 1893.csv")
125-
126-
```
127-
128190

129191
```{r, eval=F}
130192
write.csv(df1892, "../data/df1892.csv", row.names = FALSE)

reports/data-wells.html

Lines changed: 1257 additions & 113 deletions
Large diffs are not rendered by default.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: Document
2+
title:
3+
username:
4+
account: rpubs
5+
server: rpubs.com
6+
hostUrl: rpubs.com
7+
appId: https://api.rpubs.com/api/v1/document/1326938/c85baecf33ef41309fffff60658bc8d3
8+
bundleId: https://api.rpubs.com/api/v1/document/1326938/c85baecf33ef41309fffff60658bc8d3
9+
url: http://rpubs.com/publish/claim/1326938/f0140db45814446c9185543329d1c784
10+
version: 1
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: Publish Document
2+
title:
3+
username:
4+
account: rpubs
5+
server: rpubs.com
6+
hostUrl: rpubs.com
7+
appId: https://api.rpubs.com/api/v1/document/1326938/c85baecf33ef41309fffff60658bc8d3
8+
bundleId: https://api.rpubs.com/api/v1/document/1326938/c85baecf33ef41309fffff60658bc8d3
9+
url: http://rpubs.com/professornaite/1326938
10+
version: 1

0 commit comments

Comments
 (0)