Skip to content

Instantly share code, notes, and snippets.

Finishing up 2020

Nicholas Tierney njtierney

Finishing up 2020
View GitHub Profile
tylermorganwall / india_historical_map.R
Last active Apr 13, 2021
Historical Map of India with 3D elevation
View india_historical_map.R
#Load QGIS georeference image (see
testindia = raster::stack("1870_southern-india_modified.tif")
#Set bounding box for final map (cut off edges without data, introduced via reprojection)
india_bb = raster::extent(c(68,92,1,20))
cropped_india = raster::crop(testindia, india_bb)
#Convert to RGB array
nstrayer / simulate_mnar_data.R
Created Jan 21, 2020
R Script to simulate missing not at random data and look at performance of different imputation strategies.
View simulate_mnar_data.R
n <- 150
sensitivity_threshold <- 5
data <- tibble(
a = rgamma(n = n, shape = 5, rate = 0.5),
b = rgamma(n = n, shape = a/2, rate = 0.5)
generate_missing_data <- function(i){
View css.R
#' Create a CSS ruleset
#' Create a CSS ruleset consisting of a selector and one-or-more property declarations,
#' or, if no \code{.selector} is given, create an inline style string
#' The list of included properties is not a complete list, but rather an
#' abbreviated list from
#' \url{}
View fools_five.R
f <- function(...) {
function(df) with(df, ...)
footate <- function(.data, ...) {
dots <- list(...)
for (column in names(dots)) {
.data[[column]] <- dots[[column]](.data)
markdly / html-multiple-choice.Rmd
Last active Jun 13, 2019
Multiple choice quiz question Rmarkdown
View html-multiple-choice.Rmd
theme: cerulean
### Example html multiple choice question using Rmarkdown
<!-- Render this Rmarkdown doc to html to make an interactive html / js multiple choice question -->
trestletech / analysis.R
Last active Jul 7, 2017
Tidying of pressure-sensitive keystroke dynamics data. Raw available: . The `isJA` column represents whether or not the user currently typing is "Jeffrey Allen" -- i.e. is the user typing his own name (TRUE) or someone else's (FALSE)?
View analysis.R
download.file("", "")
words <- readr::read_csv("KSP-Word.csv")
users <- readr::read_csv("KSP-User.csv")
entries <- readr::read_csv("KSP-Entry.csv")
keypress <- readr::read_csv("KSP-KeyPress.csv")
pressure <- readr::read_csv("KSP-Pressure.csv")
View regex_separating_lookbehind.R
dat <- readr::read_csv("municipality\n- Ticino\n>> Distretto di Bellinzona\n......5001 Arbedo-Castione\n......5002 Bellinzona\n......5003 Cadenazzo\n......5004 Camorino\n")
dat %>% mutate(municipality = gsub(pattern = '[\\.\\>]|^-',
replacement = "",
municipality)) %>%
separate(col = municipality,
sep = '(?<=[0-9])\\s',
into = c ("code","municipality"),
fill = "left")
njtierney / tidy-inla.R
Created Feb 17, 2017
Gist of a little function for tidying the results of inla
View tidy-inla.R
# broom tidy method for class "inla"
tidy.inla <- function(x){
# x = model_inla
term_names <- rownames(x$summary.fixed)
tibble::as_tibble(x$summary.fixed) %>%
dplyr::mutate(terms = term_names) %>%
aammd / matrix_to_data.frame.R
Last active Jan 4, 2017
cantrip to turn a matrix into a data.frame, assuming that the first row of the matrix contains a header row
View matrix_to_data.frame.R
matrix_to_df_firstline_header <- function(mat){
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]),
santisbon /
Last active Mar 8, 2021
Deploying from Git branches adds flexibility. Bring your feature branch up to date with master and deploy it to make sure everything works. If everything looks good the branch can be merged. Otherwise, you can deploy your master branch to return production to its stable state.

Updating a feature branch

First we'll update your local master branch. Go to your local project and check out the branch you want to merge into (your local master branch)

$ git checkout master

Fetch the remote, bringing the branches and their commits from the remote repository. You can use the -p, --prune option to delete any remote-tracking references that no longer exist in the remote. Commits to master will be stored in a local branch, remotes/origin/master