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(data.table) | |
require(magrittr) | |
# bls.gov now requires contact information to download its text files | |
email <- '' | |
dt_msa <- readLines(url('https://www.bls.gov/web/metro/ssamatab1.txt', | |
headers = c('User-Agent' = email))) %>% | |
.[-(1:5)] %>% | |
data.table(var = .) %>% |
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
setwd('C:/Users/dwald/OneDrive/ZenBook backup/DWD/COVID-19 Labor Market') | |
library(readxl) | |
library(data.table) | |
library(magrittr) | |
library(seasonal) | |
# Crosswalks based on 2018-occupation-code-list-and-crosswalk.xlsx | |
# https://www.bls.gov/emp/documentation/crosswalks.htm | |
# SOC-Census OCC code crosswalk |
We can make this file beautiful and searchable if this error is corrected: It looks like row 3 should actually have 79 columns, instead of 29. in line 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
case_id,week,weight,pidwght,state,metro,region,division,ownhome,marital,employ,hhcomp,adults,kids1217,kids611,kids06,parent,age,age2,educ2,educ,income,race,affilrot,party,d3rot,ideo,regvote,sex,ident,l1,c1,usborn,relig,religopen,denom,denomot,born,jewid,secular,jdenom,year,demh1,demh2,date,sexorient_1,sexorient_2,sexorient_3,sexorient_4,sexorient_5,density,Q1rot,q1a,q1b,q1c,q1d,q2,q3,q4rot,q4a,q4b,q4c,partyln,formsplit,avaq1,avaq2rot,avaq2,avaq3,avaq4,avaq5,avaq6_1,avaq6_2,avaq6_3,avaq6_4,avaq6_5,avaq6_6,avaq7rot,avaq7a,avaq7b | |
40000042.00,825.00,2.35,,AL,2.00,3.00,6.00,1.00,3.00,6.00,4.00,2.00,0.00,2.00,0.00,1.00,42.00,,6.00,4.00,98.00,99.00,2.00,0.00,2.00,3.00,1.00,2.00,2.00,,2.00,,1.00,,,,2.00,,,,18,1.00,1.00,180620,1.00,0.00,0.00,0.00,0.00,2.00,CDBA,1.00,1.00,2.00,9.00,2.00,4.00,ACB,3.00,3.00,3.00,1.00,2.00,1.00,2.00,1.00,3.00,2.00,3.00,1.00,0.00,0.00,0.00,0.00,0.00,BA,2.00,2.00 | |
40000043.00,825.00,0.46,,TX,1.00,3.00,7.00,1.00,3.00,3.00,1.00,1.00,,,,2.00,70.00,,6.00,4.00,12.00,1.00,1.00,3.00,2.00,2.00,1.00, |
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(data.table) | |
library(magrittr) | |
dt <- fread('cps_00046.csv') | |
dt[, agegrp := paste0(floor(AGE / 5) * 5, ' to ', floor(AGE / 5) * 5 + 4)] | |
dt.sum <- dt[AGE >= 18, | |
.(sample = .N, | |
total = sum(ASECWT), | |
refper = sum(ASECWT * (RELATE %in% c(101,201))), |
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(data.table) | |
library(magrittr) | |
dt <- fread('meps_00004.csv') | |
# rename monthly insurance indicators to be sortable | |
setnames(dt, | |
c('INSJAX','INSFEX','INSMAX','INSAPX','INSMYX','INSJUX', | |
'INSJLX','INSAUX','INSSEX','INSOCX','INSNOX','INSDEX'), | |
sprintf('%02d',1:12)) |
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
DEGFIELDD fieldOfDegree | |
0000 N/A | |
1100 General Agriculture | |
1101 Agriculture Production and Management | |
1102 Agricultural Economics | |
1103 Animal Sciences | |
1104 Food Science | |
1105 Plant Science and Agronomy | |
1106 Soil Science | |
1199 Miscellaneous Agriculture |
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
month | tag1 | tag2 | tag3 | tag4 | total | |
---|---|---|---|---|---|---|
2009-07-01 00:00:00 | 2 | 0 | 0 | 0 | 2 | |
2009-10-01 00:00:00 | 2 | 0 | 0 | 0 | 2 | |
2010-01-01 00:00:00 | 3 | 2 | 0 | 0 | 5 | |
2010-04-01 00:00:00 | 7 | 0 | 0 | 0 | 7 | |
2010-07-01 00:00:00 | 8 | 1 | 0 | 0 | 9 | |
2010-10-01 00:00:00 | 12 | 2 | 0 | 0 | 13 | |
2011-01-01 00:00:00 | 20 | 6 | 0 | 0 | 25 | |
2011-04-01 00:00:00 | 20 | 4 | 0 | 0 | 23 | |
2011-07-01 00:00:00 | 35 | 14 | 0 | 0 | 47 |
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
year | country | money | |
---|---|---|---|
1970 | United States | 1000 | |
1980 | United States | 950 | |
1990 | United States | 800 | |
2000 | United States | 700 | |
1970 | China | 500 | |
1980 | China | 700 | |
1990 | China | 900 | |
2000 | China | 1300 | |
1970 | Canada | 1100 |
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(data.table) | |
ma <- function(x,n=5){filter(x,rep(1/n,n), sides=2)} | |
potholes <- fread('Mayors_Action_Center_Service_Cases.csv') | |
potholes <- potholes[KEYWORD__C == "Chuckhole" & SUBCATEGORY__C == 'Street (Chuckhole)', | |
.(CASENUMBER, | |
STATUS, | |
CREATEDDATE = as.Date(CREATEDDATE, format = "%Y-%m-%dT%H:%M:%S.000Z"), | |
CLOSEDDATE = as.Date(CLOSEDDATE, format = "%Y-%m-%dT%H:%M:%S.000Z"))] |
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(data.table) | |
library(readxl) | |
# Read data and lookup files from BLS' CFOI database | |
d <- fread('https://download.bls.gov/pub/time.series/fw/fw.data.1.AllData') | |
category2 <- fread('https://download.bls.gov/pub/time.series/fw/fw.category2')[, -3, with = F] | |
names(category2) <- c('category_code', 'category_text') | |
occupation <- fread('https://download.bls.gov/pub/time.series/fw/fw.occupation')[, -6, with = F] | |
names(occupation) <- c('occupation_code', 'occupation_text', 'display_level', 'selectable', 'sort_sequence') |