Skip to content

Instantly share code, notes, and snippets.

View JEFworks's full-sized avatar

Jean Fan JEFworks

View GitHub Profile
@JEFworks
JEFworks / ice_arrests_country.R
Created July 24, 2025 13:16
Visualizing temporal trends in country of citizenship for people arrested by ICE from Sep. 1, 2023 to Jun. 26, 2025
#############
## Dataset on ICE enforcement from Sep. 1, 2023 to Jun. 26, 2025
## Source: https://deportationdata.org/data/ice.html
#############
#############
## Read in data
#############
## Arrest data
@JEFworks
JEFworks / ice_arrests_encounters.R
Last active July 20, 2025 20:27
Visualizing temporal trends in ICE arrests and encounters across major US cities
#############
## Dataset on ICE enforcement from Sep. 1, 2023 to Jun. 26, 2025
## Data source: https://deportationdata.org/data/ice.html
#############
#############
## Read in data
#############
## Arrest data
@JEFworks
JEFworks / ice_spatial_temporal_trends.R
Created July 11, 2025 23:59
Visualizing spatial temporal trends in ICE detention data
@JEFworks
JEFworks / stairway_to_heaven.R
Last active July 17, 2024 15:25
Using R to play Stairway to Heaven with different instruments
# playing stairway to heaven using R
# hand transcribed notes
notes <- list(
'A3', 'C4', 'E4', 'A4',
c('B4', 'G#3'), 'E4', 'C4', 'B4',
c('C4', 'G3'), 'E4', 'C4', 'C5',
c('F#4', 'F#3'), 'D4', 'A3', 'F#4',
c('E4', 'F3'), 'C4', 'A3', 'C4',
NA, 'E4', 'C4', 'A3',
@JEFworks
JEFworks / fireworks.R
Last active July 4, 2024 22:19
Using gganimate to create an animation of fireworks over a background image
## following https://alistaire.rbind.io/blog/fireworks/
## but manually convert to polar coordinates to be able to add
## background image, which cannot be used with coord_polar()
library(ggplot2)
library(gganimate)
theme_set(theme_void())
## create set of points in polar coordinates
set.seed(0)
@JEFworks
JEFworks / gganimate_test.R
Last active September 20, 2023 17:29
Visualizing parameters for clustering PBMCs using gganimate
##################### Visualizing parameters for clustering PBMCs using gganimate
library(ggplot2)
library(gganimate)
## PBMC dataset
library(MUDAN)
data("pbmcA")
## Downsample to run faster
cd <- MUDAN::cleanCounts(pbmcA)[, 1:2000]
@JEFworks
JEFworks / hatching.R
Last active March 5, 2019 00:00
Hatching photo filter
#' Hatching photo filter
#'
#' @param img matrix representation of black and white image
#' @param N number of points to be used for hatching
#' @param size average size of points
#' @param var variability in size of points
#' @param step step size between shades of grey
#' @param pch point shape (note pch=4 is a hatch but other shapes can be used as well)
#'
#' @examples
@JEFworks
JEFworks / flickr.R
Created August 12, 2018 19:43
Flickr API usage in R
## Use flickr API to get 20 public images for flowers
data1 = paste0(readLines('https://api.flickr.com/services/feeds/photos_public.gne?tags=lilacs'), collapse="")
data2 = paste0(readLines('https://api.flickr.com/services/feeds/photos_public.gne?tags=cherryblossoms'), collapse="")
data3 = paste0(readLines('https://api.flickr.com/services/feeds/photos_public.gne?tags=marigolds'), collapse="")
data4 = paste0(readLines('https://api.flickr.com/services/feeds/photos_public.gne?tags=daffodils'), collapse="")
dataLines = c(
strsplit(data1, "<entry>")[[1]][-1],
strsplit(data2, "<entry>")[[1]][-1],
strsplit(data3, "<entry>")[[1]][-1],
strsplit(data4, "<entry>")[[1]][-1]
@JEFworks
JEFworks / bullseye.R
Last active July 31, 2018 00:09
Bull's eye color frequency plots
library(jpeg)
library(rvest)
## Image urls
urls <- c(
"http://www.instagram.com/p/BWIKgiuADnP/media/?size=m",
"http://www.instagram.com/p/BXY2LnqgB-g/media/?size=m",
"http://www.instagram.com/p/BZhL7zlg0cE/media/?size=m",
"http://www.instagram.com/p/BaHDmk5AOYe/media/?size=m",
"http://www.instagram.com/p/BcDKJywAMh4/media/?size=m",
@JEFworks
JEFworks / dither.R
Last active October 18, 2024 17:23
A fast Floyd-Steinberg dithering filter in C++ using Rcpp
library(Rcpp)
#' Floyd-Steinberg dithering
#'
#' @description Rcpp C++ function for Floyd-Steinberg dithering
#' More info: https://en.wikipedia.org/wiki/Floyd%E2%80%93Steinberg_dithering
#' Note, this is a C++ translation of the FloydConvolution function by Todos Logos
#' from https://www.r-bloggers.com/r-is-a-cool-image-editor-2-dithering-algorithms/
#'
#' @param x Greyscaled 2D image matrix