Skip to content

Instantly share code, notes, and snippets.

View djnavarro's full-sized avatar

Danielle Navarro djnavarro

View GitHub Profile
@djnavarro
djnavarro / thanks.R
Created August 23, 2018 09:29
thank you animation
library(tidyverse)
library(gganimate)
# initial frame
last_tbl<- tibble(
letter = c("T","H","A","N","K","Y","O","U"),
x_pos = c(1,2,3,4,5,2,3,4),
y_pos = c(3,3,3,3,3,2,2,2),
id = 1:8,
fr = 0.5
@djnavarro
djnavarro / bridge.R
Created August 24, 2018 21:12
two dimensional brownian bridge animation
library(tidyverse)
library(e1071)
library(gganimate)
# parameters for the simulation
ntimes <- 100
nseries <- 20
# construct tibble storing simulation
tbl <- tibble(
@djnavarro
djnavarro / wear-it-purple.R
Last active August 31, 2018 02:07
wear it purple day animation
library(tidyverse)
library(e1071)
library(gganimate)
# take a vector of inputs and return a binary
# matrix corresponding to the character
read_letter <- function(...) {
cbind(
matrix(data = c(...), nrow = 9, ncol = 5, byrow = TRUE),
matrix(data = rep(0,9), nrow = 9, ncol = 1)
@djnavarro
djnavarro / bridge.R
Created September 2, 2018 08:19
bridge of eels animation
library(tidyverse)
library(e1071)
library(gganimate)
library(viridis)
ascii_bridge <- "
.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,1,1,1,1,1,1,1,1,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.
.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,1,1,1,1,.,1,.,.,.,.,1,.,1,1,1,1,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.
.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,1,1,1,1,.,.,.,.,1,.,.,.,.,1,.,.,.,.,1,1,1,1,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.
.,.,.,.,.,.,.,.,.,.,.,.,.,.,1,1,.,.,.,1,.,.,.,.,1,.,.,.,.,1,.,.,.,.,1,.,.,.,1,1,.,.,.,.,.,.,.,.,.,.,.,.,.,.
@djnavarro
djnavarro / ambience.R
Created October 6, 2018 04:24
animated worley noise (or perlin noise)
library(ambient)
library(imager)
library(tidyverse)
library(gganimate)
make_noise_frame <- function(n=500, fr=1, type = "worley") {
if(type == "worley") {
noise <- noise_worley(
dim = c(n, n),
@djnavarro
djnavarro / ascii-brain.R
Created October 30, 2018 01:42
image of a brain constructed using the ASCII chars in an R command
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])
@djnavarro
djnavarro / parse_gae_data.R
Created December 28, 2018 00:37
Typical method for tidying data from one of my jsPsych experiments hosted on Google App Engine
# 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")
# 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 / thank_you_stars.R
Created January 30, 2019 11:17
animated thank you message made from stars
# 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")
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)