Skip to content

Instantly share code, notes, and snippets.

View trinker's full-sized avatar

Tyler Rinker trinker

View GitHub Profile
@trinker
trinker / final.png
Created October 20, 2017 19:19 — forked from hrbrmstr/final.png
composite a footer onto a ggplot plot – highly recommend doubling h & w, res = 144 and more customizing. this was a quick hack for someone.
final.png
@trinker
trinker / final.png
Created October 20, 2017 19:19 — forked from hrbrmstr/final.png
composite a footer onto a ggplot plot – highly recommend doubling h & w, res = 144 and more customizing. this was a quick hack for someone.
final.png
@trinker
trinker / images_as_xaxis_labels_updated.R
Created March 4, 2017 17:32 — forked from jonocarroll/images_as_xaxis_labels_updated.R
Implements @baptiste's much better method for making this work
library(ggplot2) ## devtools::install_github("hadley/ggplot2)
library(grid) ## rasterGrob
library(EBImage) ## readImage
library(ggthemes) ## theme_minimal
## ##########
## INDEPENDENT CODE TO BE SOURCED:
## ##########
# user-level interface to the element grob
@trinker
trinker / images_as_xaxis_labels_updated.R
Created March 4, 2017 17:32 — forked from jonocarroll/images_as_xaxis_labels_updated.R
Implements @baptiste's much better method for making this work
library(ggplot2) ## devtools::install_github("hadley/ggplot2)
library(grid) ## rasterGrob
library(EBImage) ## readImage
library(ggthemes) ## theme_minimal
## ##########
## INDEPENDENT CODE TO BE SOURCED:
## ##########
# user-level interface to the element grob
@trinker
trinker / favicon.R
Created September 22, 2016 14:49 — forked from jeroen/favicon.R
Generate favicon with magick
library(magick)
library(magrittr)
# Convert to 'ico' format
image_read("https://www.r-project.org/logo/Rlogo.png") %>%
image_scale("32x32!") %>% # remove the "!" after 32x32 to scale proportionally
image_write("favicon.ico", format = "ico")
# Favicon can also be png/gif
library(idbr)
library(ggplot2)
library(gganimate)
library(tweenr)
library(countrycode)
library(dplyr)
idb_api_key("Your API key goes here")
africa_fips <- countrycode(c('Nigeria', 'Uganda', 'Tanzania', 'Ghana'),
@trinker
trinker / topicmodels_json_ldavis.R
Created September 28, 2015 19:39 — forked from christophergandrud/topicmodels_json_ldavis.R
Convert the output of a topicmodels Latent Dirichlet Allocation model to JSON for use with LDAvis
#' Convert the output of a topicmodels Latent Dirichlet Allocation to JSON
#' for use with LDAvis
#'
#' @param fitted Output from a topicmodels \code{LDA} model.
#' @param corpus Corpus object used to create the document term
#' matrix for the \code{LDA} model. This should have been create with
#' the tm package's \code{Corpus} function.
#' @param doc_term The document term matrix used in the \code{LDA}
#' model. This should have been created with the tm package's
#' \code{DocumentTermMatrix} function.
@trinker
trinker / knitr
Last active August 29, 2015 14:15 — forked from pdparker/knitr
# Makefile to use knitr for presentations
SLIDES := Day1Part1-Introduction.html Day1Part1-session2.html Day1Part1-session3.html Day1Part2-session1.Rmd
all: $(SLIDES)
clean:
rm -rf *.md mplus.*
%.html: %.Rmd
# R Function to Draw Edward Tufte-style Slopeplots
# TODO:
## deal with overlapping numeric values: if more than one label falls at a position, offset based on rank() of the subsequent column values for those rows
## overlapping rownames (same algorithm as above, but hard code for 1st and 2nd value)
slopegraph <-
function(
df,