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
library(tidyverse) | |
# Get number of incidents of selected types of force by county | |
# devtools::install_github("tor-gu/njoaguof") | |
library(njoaguof) | |
force_type_by_county <- incident %>% | |
right_join(incident_subject_force_type) %>% | |
mutate( | |
force_type = | |
fct_collapse( |
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
library(tidyverse) | |
library(lubridate) | |
library(njoaguof) | |
# Get number proportion of incidents with body worn camera or any video | |
# by county and by 4-month interval | |
# devtools::install_github("tor-gu/njoaguof") | |
video_by_county <- incident %>% | |
left_join(incident_video_type) %>% | |
select(form_id, |
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
# Tidyverse packages | |
library(dplyr) | |
library(magrittr) | |
library(purrr) | |
# Maps and census libraries | |
# *** Note: CENSUS API Key required *** | |
library(sf) | |
library(tidycensus) | |
library(tigris) |
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
library(tidyverse) | |
library(future) | |
library(furrr) | |
library(gganimate) | |
plan(multisession, workers = 12) | |
cf_init <- function(D) { | |
r = as.integer(floor((sqrt(D)))) | |
list( | |
D = D, r = r, a = r, b = r, c = D - r ^ 2 |
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
library(tidyverse) | |
library(tigris) | |
library(njmunicipalities) | |
library(njelections) | |
county_names <- njmunicipalities::counties |> pull(county) | |
# Get the map of NJ | |
options(tigris_use_cache = TRUE) | |
nj_municipality_map <- county_names %>% | |
map_df( ~ county_subdivisions("NJ", county = ., class = "sf")) |> |
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
import numpy as np | |
from matplotlib import pyplot as plt | |
from scipy.optimize import LinearConstraint, minimize | |
np.random.seed(3737) | |
LO, HI = 0, 100 | |
n = 100 # Number of points | |
k = 73 # Points to remove |