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(tidyverse) | |
library(ggmap) | |
#Test number must be of the form of a number (ndx) followed by a single letter (version). | |
is_valid_test_nbr <- function(test_nbr) grepl("^[0-9]+[A-Za-z]?{1}$",test_nbr) | |
##Test | |
identical(is_valid_test_nbr(c("A","123","123A","123AB","_123A","_123","_A")), | |
c(FALSE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE)) |
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
// Will be parameters | |
var PARAM_EVENT_NAME = "My Event Name" | |
var PARAM_LOCATION = "Mountain View, CA" | |
var PARAM_DESCRIPTION = "My Description" | |
var PARAM_START_DATE = "12/08/2019" | |
var PARAM_START_TIME = "7:00 PM" | |
var PARAM_END_DATE = "12/08/2019" | |
var PARAM_END_TIME = "9:00 PM" | |
// Xpaths |
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(ggplot2) | |
library(ggthemes) | |
dat <- data.frame( | |
party = c('con', 'lab', 'snp', 'lib', 'dup', 'sf', 'pc', 'green', 'ukip_brexit'), | |
party_label = c('Conservative', 'Labour', 'Scottish National', 'Liberal Democrats', | |
'Democratic Unionist', 'Sinn Fein', 'Plaid Cymru', 'Green', 'Brexit & UKIP'), | |
vote_2017 = c(13636684, 12877918, 977568, 2371861, 292316, 238915, 164466, 525665, 594068), | |
vote_2019 = c(13941200, 10292054, 1242372, 3675342, 244128, 181853, 153265, 864743, 665120), | |
seats_2017 = c(317, 262, 35, 12, 10, 7, 4, 1, 0), | |
seats_2019 = c(364, 203, 48, 11, 8, 7, 4, 1, 0), |
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
# Setup ------------------------------------------------------------------- | |
library(htmltab) | |
library(dplyr) | |
library(tidyr) | |
library(ggplot2) | |
url <- 'https://www.politico.com/2020-election/results/super-tuesday/' | |
# Parse ------------------------------------------------------------------- |
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
# Setup ------------------------------------------------------------------- | |
library(htmltab) | |
library(dplyr) | |
library(ggplot2) | |
library(knitr) | |
library(scales) | |
url <- 'https://docquery.fec.gov/cgi-bin/forms/C00739110/1391696//sa/ALL' | |
# Parse ------------------------------------------------------------------- |
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(ggplot2) | |
url <- 'https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv' | |
dat <- read.csv(url, header = TRUE, stringsAsFactors = FALSE) | |
scc <- dat[dat$county == 'Santa Clara' & dat$state == 'California', ] | |
scc$date <- as.Date(scc$date) | |
scc <- scc[order(scc$date), ] | |
# County advises that the five most recent days may change. | |
# So remove those days from analysis. | |
scc <- scc[!(scc$date %in% seq.Date(from = Sys.Date() - 4, to = Sys.Date(), by = 1)), ] | |
scc$incremental_cases <- scc$cases - c(NA_integer_, scc$cases[-nrow(scc)]) |
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
suppressPackageStartupMessages(library(data.table)) | |
suppressPackageStartupMessages(library(janitor)) | |
suppressPackageStartupMessages(library(lubridate)) | |
suppressPackageStartupMessages(library(tidyr)) | |
suppressPackageStartupMessages(library(dplyr)) | |
# load and transform ------------------------------------------------------ | |
vts <- | |
fread('data/Vote Archive - Public-Grid view.csv', encoding = 'UTF-8') |> |