Skip to content

Instantly share code, notes, and snippets.

{"request":{"command":"series","series_id":"EBA.LGEE-ALL.D.H"},"series":[{"series_id":"EBA.LGEE-ALL.D.H","name":"Demand for LG&E and KU Services Company as agent for Louisville Gas and Electric Company and Kentucky Utilities Company (LGEE), Hourly","units":"megawatthours","f":"H","description":"Timestamps follow the ISO8601 standard (https:\/\/en.wikipedia.org\/wiki\/ISO_8601). Hourly representations are provided in Universal Time.","start":"20150701T00Z","end":"20180201T16Z","updated":"2018-02-01T12:02:29-0500","data":[["20180201T16Z",4392],["20180201T15Z",4363],["20180201T14Z",4385],["20180201T13Z",4387],["20180201T12Z",4171],["20180201T11Z",3818],["20180201T10Z",3622],["20180201T09Z",3586],["20180201T08Z",3628],["20180201T07Z",3644],["20180201T06Z",3725],["20180201T05Z",3866],["20180201T04Z",4050],["20180201T03Z",4255],["20180201T02Z",4408],["20180201T01Z",4419],["20180201T00Z",4384],["20180131T23Z",4105],["20180131T22Z",4050],["20180131T21Z",4142],["20180131T20Z",4197],["20180131T19Z",4368],["20180131T18Z
@Smudgerville
Smudgerville / lou.csv
Last active February 1, 2018 16:43
Bowman Field Temperature & Humidity
We can't make this file beautiful and searchable because it's too large.
DateTime,Station,Temp,Humidity,Fcst_Time,Source
2015-01-01 00:00:00.000,KLOU,23,52,1900-01-01 00:00:00.000,Weather DB
2015-01-01 01:00:00.000,KLOU,23,55,1900-01-01 00:00:00.000,Weather DB
2015-01-01 02:00:00.000,KLOU,23,55,1900-01-01 00:00:00.000,Weather DB
2015-01-01 03:00:00.000,KLOU,23,57,1900-01-01 00:00:00.000,Weather DB
2015-01-01 04:00:00.000,KLOU,23,57,1900-01-01 00:00:00.000,Weather DB
2015-01-01 05:00:00.000,KLOU,24,58,1900-01-01 00:00:00.000,Weather DB
2015-01-01 06:00:00.000,KLOU,24,58,1900-01-01 00:00:00.000,Weather DB
2015-01-01 07:00:00.000,KLOU,23,63,1900-01-01 00:00:00.000,Weather DB
2015-01-01 08:00:00.000,KLOU,25,58,1900-01-01 00:00:00.000,Weather DB
@Smudgerville
Smudgerville / Time_Series_Packages.R
Last active January 13, 2018 18:27
Packages for BUMSA18 Time Series
pks <- c("forecast", "lubridate", "xts", "zoo", "ggplot2", "fpp2", "seasonal", "devtools", "dygraphs", "quantmod", "DT", "knitr", "rmarkdown", "shiny", "shinydashboard", "roxygen2")
install.packages(pks[!pks %in% installed.packages()])
@Smudgerville
Smudgerville / No_Outer_Join.R
Created December 12, 2017 13:16
Silly example to overcome no right / outer join in sqldf
require(sqldf)
a <- c(1, 3, 5, 7, 9)
b <- c(1:3, 8:10)
df <- data.frame(Both = union(a, b))
a <- data.frame(a = a)
b <- data.frame(b = b)
sqldf("SELECT df.*, a.a, b.b FROM df LEFT JOIN a ON df.Both = a.a LEFT JOIN b ON df.Both = b.b ORDER BY df.Both")
@Smudgerville
Smudgerville / Folder_Walk.R
Created December 8, 2017 20:59
Navigate through monthly folders with preferred org structure YYYY > MM_MMM (e.g. 2017 > 01_Jan, 02_Feb)
folder_walk <- function(currMonth = month, walk = -1, mydir = home_dir) {
# requries lubridate
# currMonth in format YYYYMM
# walk as integer (+ve / -ve)
# home_dir - filepath where date/time folders are based
in_month <- as.Date(paste(substr(currMonth, 1, 4), substr(currMonth, 5, 6), "01", sep = "-"))
out_month <- in_month
lubridate::month(out_month) <- lubridate::month(in_month) + as.numeric(walk)
folders <- data.frame(Number = formatC(seq(1:12), width = 2, format = "d", flag = "0"), Month = month.abb)
folders <- dplyr::transmute(folders, Folder = paste(Number, Month, sep = "_"))
@Smudgerville
Smudgerville / R_Notebook_from_Gist.R
Created December 8, 2017 20:57
Create an R Notebook with preferred YAML
require(RCurl);
nb_url <- "https://gist.githubusercontent.com/Smudgerville/7e91e7fad887df4339090f1183be9967/raw/84c1b57453d1be7c3f381bbf7177233c5c83b0ba/r_notebook_web.yaml"
nb_yaml <- readLines(nb_url)
file.create("H:/Temp/Test_Notebook.Rmd")
writeLines(nb_yaml, "H:/Temp/Test_Notebook.Rmd")
@Smudgerville
Smudgerville / ReadMe.yaml
Created December 7, 2017 20:14
Standard Front Matter for ReadMe files
---
author:
date:
---
---
title: ""
date: ""
output:
html_notebook:
fig_caption: yes
highlight: textmate
theme: cosmo
toc: yes
toc_depth: 4
@Smudgerville
Smudgerville / labeled_binary_df.R
Created May 24, 2017 22:06
Data frame of monthly binaries
a <- paste(month.abb, "Binary", sep = "_")
df <- data.frame(matrix(vector(), 0, 12, dimnames = list(c(), a)), stringsAsFactors = F)
for(i in 1:length(month.abb)) {
df[i,] <- as.numeric(substr(a, 1, 3)==month.abb[i])
}
@Smudgerville
Smudgerville / read_sql_query_folder.R
Created May 24, 2017 18:31
Read in SQL statements from all files in a Query subfolder
qry_files <- list.files(paste0(home_dir, "/Queries"), full.names = T)
for(i in 1:length(qry_files)) {
# wouldn't work with periods in the actual file name
assign(gsub("\\.(.*)", "", basename(qry_files))[i], readChar(qry_files[i], nchar = file.info(qry_files[i])$size))
}