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) | |
#you'll need this file, available in my repo, at | |
#https://github.com/CharlesFainLehman/Rikers-DIC/blob/main/dat/via_github/DOC_Inmates_InCustody_Daily_20231127.csv | |
#You can also use any other DIC file, though, updated daily at | |
#https://data.cityofnewyork.us/Public-Safety/Daily-Inmates-In-Custody/7479-ugqb | |
#or stored in my github repo at | |
#https://github.com/CharlesFainLehman/Rikers-DIC/ | |
rikers_11_26_23 <- read.csv("Daily_Inmates_In_Custody_20231127.csv") |
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(haven) | |
library(stargazer) | |
library(tidyverse) | |
#Obviously you'll need to download the ATP data (linked in the post) and put them in the right directory relative to this script. | |
atp47 <- read_sav("W47_Apr19/ATP W47.sav") | |
atp104 <- read_sav("W104_Mar22/ATP W104.sav") | |
#Convert the spectrum of agree/disagree to binary variable, and drop the non-responses | |
atp47 %>% |
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
#You'll need to get the data for deaths and population from CDC WONDER. | |
#you can get my deaths file here: https://wonder.cdc.gov/controller/saved/D176/D358F098 | |
#and you can get my population file here: https://wonder.cdc.gov/controller/saved/D176/D358F099 | |
#Rename them appropriately for importation | |
library(tidyverse) | |
library(tidysynth) | |
library(ggpubr) | |
#don't forget to rename this file |
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
### Keybase proof | |
I hereby claim: | |
* I am charlesfainlehman on github. | |
* I am charlesflehman (https://keybase.io/charlesflehman) on keybase. | |
* I have a public key ASA7SWFEfTDuVxcymqLvrhMNoxjnxEjld_FGDksnShQjbwo | |
To claim this, I am signing this object: |
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
require 'net/http' | |
require 'open-uri' | |
links = [] | |
if (ARGV[0] != nil) | |
links = [ARGV[0]] | |
else | |
links = ["http://en.wikipedia.org/wiki/Ruby_(programming_language)"] | |
end | |
i = 0 | |
c = 1 |
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
@values = {"a" => 1, "b" => 3, "c" => 3, "d" => 2, "e" => 1, "f" => 4, "g" => 2, "h" => 4, "i" => 1, "j" => 8, "k" => 5, "l" => 1, "m" => 3, "n" => 1, "o" => 1, "p" => 3, "q" => 10, "r" => 1, "s" => 1, "t" => 1, "u" => 1, "v" => 4, "w" => 4, "x" => 8, "y" => 4, "z" => 10} | |
def getChar(c) | |
@values[c.downcase] | |
end | |
def getWord(w) | |
sum = 0 | |
w.each_char do |c| | |
sum += getChar c unless getChar(c).nil? |
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
def mean(set) | |
set.length < 2 ? set[0] : (set[0] + mean set[1..set.length]) / set.length.to_f | |
end | |
def sigma(set) | |
set.length < 2 ? set[0] : set[0] + sigma set[1..set.length] | |
end | |
def is_prime?(val, c=(val-1)) | |
c < 2 or c >= val ? false : (val/(c.to_f)) - (val/c) == 0 ? false : is_prime?(val, c - 1) |