This file contains hidden or 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(blscrapeR) | |
library(dplyr) | |
library(stringr) | |
library(data.table) | |
# Using fread from data.table here becuse it's much faster and the first file is pretty huge. | |
doc <- data.table::fread("https://download.bls.gov/pub/time.series/oe/oe.data.0.Current") | |
titles <- data.table::fread("https://download.bls.gov/pub/time.series/oe/oe.occupation") | |
data_type <- data.table::fread("https://download.bls.gov/pub/time.series/oe/oe.datatype") |
This file contains hidden or 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
# BB-8 -------------------------------------------------------------------- | |
# Inspired by Brian Hough in http://codepen.io/bhough/pen/wawrPL | |
# Packages ---------------------------------------------------------------- | |
library("dplyr") | |
library("ggplot2") |
This file contains hidden or 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
CREATE TABLE PrimPos AS | |
SELECT playerID | |
, yearID | |
, teamID | |
, MAX(G) AS G | |
, POS | |
FROM (SELECT * from fielding | |
WHERE IF(yearID>1995 AND POS = "OF",1,0) != 1 ORDER BY G Desc) f | |
GROUP BY playerID, yearID, teamID, POS; |
This file contains hidden or 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(Lahman); library(dplyr) | |
# Find primary positions | |
fielding <- Lahman::Fielding | |
# The "postf" field below is to filter out Natl. League players who may have | |
# played as DH in inter-leauge games, and may have multiple entries at diff. positions. | |
PrimPos <- dplyr::mutate(fielding, postf=ifelse(POS=="OF" & yearID>1995, 1,0)) %>% | |
subset(postf==0, select=c("playerID", "yearID", "teamID", "lgID","G", "POS")) %>% | |
group_by(playerID, yearID, teamID, lgID, POS) %>% | |
summarise(G = sum(G)) |
This file contains hidden or 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
# Makes sure the required packs are loaed, if not, intalles them. | |
pkgs <-c ('sp','ggplot2','rgdal','broom','maptools','tigris', 'blscrapeR') | |
for(p in pkgs) if(p %in% rownames(installed.packages()) == FALSE) {install.packages(p, repos='http://cran.us.r-project.org')} | |
for(p in pkgs) suppressPackageStartupMessages(library(p, quietly=TRUE, character.only=TRUE)) | |
# Before we get into the projections, let's download some unemployment data to map. | |
county_dat <- get_bls_county() | |
# We also need a shapefile with the appropriate FIPS codes. | |
state <- counties(cb = TRUE, year = 2015) |
This file contains hidden or 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(blscrapeR) | |
library(ggplot2) | |
library(dplyr) | |
# Get the current county data from blscrapeR. | |
df <- get_bls_county(stateName = "Ohio") | |
# Grap the internal FIPS codes data set from blscrapeR so we can match on counties. | |
fips <- blscrapeR::county_fips | |
# Subset fips list to only Ohio counties. | |
fips <- subset(fips, state=="OH") |
This file contains hidden or 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
@ECHO OFF | |
cd /nginx | |
taskkill /f /IM nginx.exe | |
start nginx | |
EXIT |
This file contains hidden or 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(plyr); library(dplyr); library(leaflet); library(stringi); | |
library(htmltools); library(RColorBrewer); library(rvest) | |
# Parse and read storm track data. | |
html <- read_html('http://weather.unisys.com/hurricane/atlantic/2016/index.php') | |
links <- html_attr(html_nodes(html, "a"), "href") | |
links <- links[grep('track.dat', links)] | |
track <- select.list(links, title="Select storm:", graphics = FALSE) | |
#track <- "MATTHEW/track.dat" |
This file contains hidden or 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(sp) | |
library(rgeos) | |
library(rgdal) | |
library(maptools) | |
library(dplyr) | |
library(leaflet) | |
library(scales) | |
### Begin data prep | |
# Grab air/water quality data from the EPA | |
url = "https://data.cdc.gov/api/views/cjae-szjv/rows.csv?accessType=DOWNLOAD" |
This file contains hidden or 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
# Grab air/water quality data from the EPA | |
url = "https://data.cdc.gov/api/views/cjae-szjv/rows.csv?accessType=DOWNLOAD" | |
dat <- read.csv(url, stringsAsFactors = FALSE) | |
# Colnames tolower | |
names(dat) <- tolower(names(dat)) | |
dat$countyname <- tolower(dat$countyname) | |
# Wide data set, subset only what we need. | |
county_dat <- subset(dat, measureid == "296", | |
select = c("countyfips","statename", "countyname", "value", "unitname")) | |
# Rename columns to make for a clean df merge later. |
NewerOlder