/graphics

graphics functions for maps and chart production in the standard OPA style

Primary LanguageR

OPA graphics functions

These are some helpful functions and a ggplot theme for making charts in the OPA key. Use this repo as the authoritative source for these charting functions. Meaning, push any improvements you make to this repo so the charts the office makes are standardized.

Pull these functions into your script with:

source_https <- function(u, unlink.tmp.certs = FALSE) {
    # load package
    require(RCurl)

    # read script lines from website using a security certificate
    if(!file.exists("cacert.pem")) download.file(url="http://curl.haxx.se/ca/cacert.pem", destfile = "cacert.pem")
    script <- getURL(u, followlocation = TRUE, cainfo = "cacert.pem")
    if(unlink.tmp.certs) unlink("cacert.pem")

    # parase lines and evealuate in the global environement
    eval(parse(text = script), envir= .GlobalEnv)
}

Then:

source_https("https://raw.githubusercontent.com/cno-opa/graphics/master/WHICHEVER-FILE-YOU-WANT")

See how the stat template incorporates this into main.R

Thanks to Tony Breyal for the above function.

For mappers.R, see this tutorial.