Skip to content

Instantly share code, notes, and snippets.

💖
Sparkly

Danielle Navarro djnavarro

💖
Sparkly
Block or report user

Report or block djnavarro

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View make_map2.R
library(geojsonio)
library(here)
library(broom)
reload <- FALSE
if(reload) {
spdf <- geojson_read(
x = here("unsw_map", "worldgeo.json"),
what = "sp"
)
@djnavarro
djnavarro / bayes_rain_viewer.R
Created Mar 12, 2019
Uses the asciify package to draw the "Bayesian rain" animation in the RStudio viewer pane
View bayes_rain_viewer.R
#devtools::install_github("djnavarro/asciify")
library(asciify)
library(magrittr)
temporary <- function(file) {
temp_dir <- tempfile()
dir.create(temp_dir)
file.path(temp_dir, file)
}
@djnavarro
djnavarro / bb_gapminder.R
Created Feb 26, 2019
draws the gganimate gapminder example, using bbc style
View bb_gapminder.R
# packages
library(tidyverse)
library(gganimate)
library(gapminder)
library(scales)
# modified version of the bbc_style function
# adapted from: https://github.com/bbc/bbplot
bbc_style2 <- function(font = "Helvetica") {
theme(
View thank_you_solid_stars.R
library(showtext)
library(fontr)
library(tidyverse)
library(transformr)
library(animation)
library(ggpolypath)
# use showfont to load the font
font_add_google("Allura")
@djnavarro
djnavarro / lissajous_transform.R
Created Feb 4, 2019
Tween between two lissajous curves using transformr
View lissajous_transform.R
library(tidyverse)
library(transformr)
library(tweenr)
library(animation)
# function to generate lissajous curves in a format
# suitable for later tweening
lissajous <- function(a=1, b=1, w=1, d=pi/2, t0=-pi, t1=pi, n=100) {
tibble(
t = seq(t0, t1, length.out = n),
View isoband_lgbt.R
library(isoband)
library(magick)
library(sf)
library(tidyverse)
# Adapted from Claus Wilke's code
# https://github.com/clauswilke/isoband
sf_from_image <- function(image, nbands) {
image_gray <- image %>% image_quantize(colorspace = "gray")
image_raster <- as.raster(image_gray)
@djnavarro
djnavarro / thank_you_stars.R
Created Jan 30, 2019
animated thank you message made from stars
View thank_you_stars.R
# devtools::install_github("yixuan/fontr")
library(fontr)
library(transformr)
library(showtext)
library(tidyverse)
library(gganimate)
# use showtext to loading Google fonts (http://www.google.com/fonts)
font_add_google("Allura")
View isoband_example.R
# Adapted from Claus Wilke's code
# https://github.com/clauswilke/isoband
library(isoband)
library(magick)
library(sf)
library(tidyverse)
# my twitter profile
img_loc <- "https://pbs.twimg.com/profile_images/1088575199568584704/zGiMgFB7_400x400.jpg"
@djnavarro
djnavarro / parse_gae_data.R
Created Dec 28, 2018
Typical method for tidying data from one of my jsPsych experiments hosted on Google App Engine
View parse_gae_data.R
# Script for tidying data pulled from Google App Engine. Typically the raw format
# has a "content" field, and each entry in it is a text string describing the
# complete data set from one person in CSV format.
library(tidyverse)
my_data <- read_csv("results.csv") %>%
pull("content") %>%
map_dfr(read_csv, col_types = cols(.default = "c")) %>%
write_csv("tidy_results.csv")
@djnavarro
djnavarro / ascii-brain.R
Created Oct 30, 2018
image of a brain constructed using the ASCII chars in an R command
View ascii-brain.R
library(tidyverse)
library(imager)
# function to convert an image to an ascii character map
asciify <- function(file, charset, threshold){
# load image
im <- load.image(file)
im <- as.cimg(im[,,1:3])
You can’t perform that action at this time.