Skip to content

Instantly share code, notes, and snippets.

View trinker's full-sized avatar

Tyler Rinker trinker

View GitHub Profile
@hrbrmstr
hrbrmstr / final.png
Last active March 3, 2019 05:27
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
library(gh)
library(tidyverse)
library("magick")
library(glue)
dir.create("data")
repos <- gh::gh("/orgs/:org/repos", org = "tidyverse", .limit = Inf) %>% map_chr("name")
urls <- repos %>%
@halhen
halhen / joyplot-atus.R
Last active July 17, 2018 13:20
The daily grind - viz
library(tidyverse)
# data from https://www.kaggle.com/bls/american-time-use-survey
df.resp <- read_csv('../data/atus/atusresp.csv')
df.act <- read_csv('../data/atus/atusact.csv', col_types=cols(tustarttim = col_character(), tustoptime = col_character()))
df.sum <- read_csv('../data/atus/atussum.csv')
df.tmp <- df.act %>%
mutate(activity = case_when(trtier2p == 1301 ~ 'Exercise',
@jeroen
jeroen / favicon.R
Last active February 14, 2019 21:32
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'),
```r
p_load_gh("jcheng5/bubbles", "trinker/qdapTools")
x <- runif(26)
colfunc <- colorRampPalette(c("white", "red"))
cols <- colfunc(length(sort(unique(x))))
bubbles(value = x, label = LETTERS,
@hrbrmstr
hrbrmstr / us_states_hexgrid.geojson
Last active April 9, 2021 06:10
hexbin faceted choropleths in R
library(rgdal)
library(rgeos)
library(ggplot2)
library(readr)
library(tidyr)
library(dplyr)
library(grid)
us <- readOGR("us_states_hexgrid.geojson", "OGRGeoJSON")
@abresler
abresler / netsdaily_polarity_plot
Last active December 18, 2015 15:17
Netsdaily Polarity Plot in R
### Parsing Netsdaily for a Polarity Plot -- working with JSON
packages <-
c('magrittr', 'dplyr', 'qdap', 'jsonlite', 'ggplot2')
lapply(packages, library, character.only = T)
url <-
'http://www.netsdaily.com/comments/load_comments/8261850'
data <-
url %>%
@bryangoodrich
bryangoodrich / TwitterTopics.r
Last active June 29, 2022 20:33
Twitter Topic Modeling Using R
# Twitter Topic Modeling Using R
# Author: Bryan Goodrich
# Date Created: February 13, 2015
# Last Modified: April 3, 2015
#
# Use twitteR API to query Twitter, parse the search result, and
# perform a series of topic models for identifying potentially
# useful topics from your query content. This has applications for
# social media, research, or general curiosity
#
@bryangoodrich
bryangoodrich / PercolationModel.py
Created March 17, 2015 06:42
Using Union-Find Data Structure to Model Percolation System
import array
class WeightedQuickUnion:
def __init__(self, N):
self.count = N
self.id = array.array('i', range(N))
self.size = array.array('i', [1] * N)
def connected(self, p, q):
return self.find(p) == self.find(q)