Skip to content

Instantly share code, notes, and snippets.

View njtierney's full-sized avatar
🐝
Back at work

Nicholas Tierney njtierney

🐝
Back at work
View GitHub Profile
@njtierney
njtierney / advise.md
Created August 18, 2016 09:17 — forked from hadley/advise.md
Advise for teaching an R workshop

I think the two most important messages that people can get from a short course are:

a) the material is important and worthwhile to learn (even if it's challenging), and b) it's possible to learn it!

For those reasons, I usually start by diving as quickly as possible into visualisation. I think it's a bad idea to start by explicitly teaching programming concepts (like data structures), because the pay off isn't obvious. If you start with visualisation, the pay off is really obvious and people are more motivated to push past any initial teething problems. In stat405, I used to start with some very basic templates that got people up and running with scatterplots and histograms - they wouldn't necessary understand the code, but they'd know which bits could be varied for different effects.

Apart from visualisation, I think the two most important topics to cover are tidy data (i.e. http://www.jstatsoft.org/v59/i10/ + tidyr) and data manipulation (dplyr). These are both important for when people go off and apply

@njtierney
njtierney / Makefile
Created September 20, 2016 05:58 — forked from PirateGrunt/Makefile
Basic makefile
####################
# Makefile
# Copyright Brian A. Fannin 2015
####################
RDIR = .
DATA_DIR = $(RDIR)/data
GATHER_DIR = $(DATA_DIR)/gather
GATHER_SOURCE = $(wildcard $(GATHER_DIR)/*.Rmd)
@njtierney
njtierney / matrix_to_data.frame.R
Created January 4, 2017 01:31 — forked from aammd/matrix_to_data.frame.R
cantrip to turn a matrix into a data.frame, assuming that the first row of the matrix contains a header row
matrix_to_df_firstline_header <- function(mat){
requireNamespace("purrr")
mat %>%
## cut columns into lists
apply(2, function(s) list(s)) %>%
flatten %>%
map(flatten_chr) %>%
## set names to the first element of the list
{set_names(x = map(., ~ .x[-1]),
# (1) Get a free plan from https://openexchangerates.org/signup/free
# (2) Tell this function your API key:
# from this section of the site: https://openexchangerates.org/account/app-ids
# Sys.setenv(OER_KEY = "paste-your-very-long-numeric-string-here")
Sys.setenv(OER_KEY = "OER_KEY")
library(glue)
library(tidyverse)
get_day <- function(day) {
u <- glue("https://openexchangerates.org/api/historical/{day}.json?app_id=\\