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(extrafont) | |
library(tidyverse) | |
library(scales) | |
myfont <- "Roboto" | |
main_font <- "Roboto" | |
heading_font <- "Sarala" | |
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
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, |
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
#---------------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") | |
x*100/ref | |
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
#----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 http://www.sciviews.org/_rgui/tcltk/ModalDialog.html | |
require(tcltk) | |
dlg <- tktoplevel() | |
tkwm.deiconify(dlg) |