Skip to content

Instantly share code, notes, and snippets.


Peter Ellis ellisp

View GitHub Profile
ellisp / us-update.R
Created Nov 6, 2020
Plot of the latest for the votecount for the 2020 US election in selected states
View us-update.R
myfont <- "Roboto"
main_font <- "Roboto"
heading_font <- "Sarala"
View dualplot.R
dualplot <- function(x1, y1, y2, x2 = x1,
col = c("#C54E6D", "#009380"),
lwd = c(1, 1), colgrid = NULL,
mar = c(3, 6, 3, 6) + 0.1,
ylab1 = paste(substitute(y1), collapse = ""),
ylab2 = paste(substitute(y2), collapse = ""),
nxbreaks = 5,
yleg1 = paste(gsub("\n$", "", ylab1), "(left axis)"),
yleg2 = paste(ylab2, "(right axis)"),
ylim1 = NULL, ylim2 = NULL, ylim.ref = NULL,
ellisp / OnTheFly.R
Last active Dec 26, 2015
seasonal adjustment, indexing and rolling averages on the fly within ggplot in R
View OnTheFly.R
#---------------Index and Index12---------------
Index <- function(x, ref=x[1]){
# Function that takes a vector or time series (or any object actually)
# and returns it as an index based on 100. Defaults to using the
# first value of the vector as reference value, but this can be overridden.
if(length(ref)>1) stop("Reference value must be a single number")
ellisp / Creds.R
Last active Dec 26, 2015
A utility for handling user credentials to databases
View Creds.R
#----AskCreds - so RStudio can access ODBC-------------------
AskCreds <- function(Title="User credentials for a database", startuid="", returnValOnCancel = "ID_CANCEL") {
# Peter Ellis, 12 August 2013
# A wrapper function to provide a GUI to ask a user for user id and password so they
# can be given to a database in a future call of connectODBC()
# Based on
dlg <- tktoplevel()