Publications by Sarah Cohen
Demographics of Maricopa precincts
I downloaded some basic demographics tables for block groups from Social Explorer. THe first data table just has voting age citizens by race and ethnicity. The second has full population numbers for race & ethnicity, income in ranges (to calculate approx. medians with cumulative numbers), and education (collapsed) import citizenship information ...
1444 sym R (9370 sym/8 pcs)
Example maps
Philadelphia County This map shows each Zip Code area in Philadelphia County, shaded by the main race / ethnic group in the zip code. The darker the shading, the greater the percent of businesses that obtained loans through the PPP. The circles are also scaled to that measure. Click on an area to see the details. Washington, DC Metro area This m...
1155 sym
Homework 1
Import Excel file I downloaded an Excel file from the R Study Guide , at the bottom of the page, and saved it into this project. I need to import it into R: my_grants <- read_excel("nea_grants.xlsx") Let’s take a look at it, first showing the top, then showing the bottom, then showing the structure of the dataset: Top: head(my_grants) Now the ...
6384 sym R (2137 sym/7 pcs)
Markdown and table styling
Getting started with GGPLOT The data A searchable, sortable table Our first chart Create a histogram A bar chart Dot plots Percentages by ethnicity Facets for ethnicity Make facets by zip code ethnicity Make a chart for each bank: 2021-11-10 Code Show All Code Hide All Code Download Rmd Getting started with GGPLOT This time I’m using...
26632 sym R (5990 sym/19 pcs) 14 img 1 tbl
R study session
This goes through a lot of the queries that you might write to work on your PPP data, but it will also serve as an example for the test. If you are having trouble figuring out what these do, try them and see what they produce. Also try running pieces in their parts. You can select everything up to (but not including) a pipe %>% and run it by hitt...
27267 sym R (5052 sym/23 pcs)
lab: Group by & mutate
Set up This is a typical setup section. If you’re having trouble knitting with errors, try changing this to error=TRUE to let it keep going when it hits a mistake. But go back and look at why – it’s sometimes easier to see in the final R markdown. This example markdown uses a new library called formattable, for formatted tables. Install it ...
11928 sym R (8223 sym/17 pcs) 3 tbl
Filtering lab
Here is a fairly typical setup section that you can copy and paste into any document. I usually just start a new document, erase everything and copy this from the top through the first code chunk. library(knitr) knitr::opts_chunk$set(echo = TRUE, warning=TRUE, message=FALSE, err...
13369 sym R (3937 sym/13 pcs)
New filtering version
Here is a fairly typical setup section that you can copy and paste into any document. I usually just start a new document, erase everything and copy this from the top through the first code chunk. library(knitr) knitr::opts_chunk$set(echo = TRUE, warning=TRUE, message=FALSE, err...
14308 sym R (4552 sym/16 pcs)
Household pulse survey example
Background Read raw data Factor labels example Recode example Weighted data Code Show All Code Hide All Code Download Rmd Read most recent HPS survey - SAS version Sarah Cohen 2021-06-13 Background This program reads in the SAS datasaet provided by Census bureau for the most recent wave of the Household Pulse Survey. Unfortunately, ther...
17983 sym R (8548 sym/9 pcs) 2 img
Scraping and regex little examples
knitr::opts_chunk$set(echo = TRUE, message=FALSE, warning=FALSE) library(tidyverse) # the usual library(rvest) # for scraping library(janitor) # the usual Use regex to find phrases and patterns for coding Some of you have had cases where there were phrases you wanted to find. You can use reg...
4942 sym R (3054 sym/6 pcs) 2 tbl