Skip to content

Instantly share code, notes, and snippets.

View sa-lee's full-sized avatar
🤠

Stuart Lee sa-lee

🤠
View GitHub Profile
@sa-lee
sa-lee / gist:a3d6f5f582485f65d111f2b287b46ac2
Last active October 29, 2019 03:04
gif a tour that shows in rmd / rstudio viewer pane
gif_tour <- function(data, tour_path, display, ... ) {
  dir <- tempdir()
  png_path <- file.path(dir, "frame%03d.png")
  
  tourr::render(data,
                tour_path = tour_path,
                display = display,
                dev = "png",
                png_path,
library(nullabor)
library(gganimate)
library(magrittr)
p <- mtcars %>%
rorschach(method = null_permute("mpg"), n = 20, true = .) %>%
ggplot() +
geom_boxplot(aes(x = factor(cyl), y = mpg, fill = factor(cyl))) +
theme(legend.position = 'none', aspect.ratio = 1) +
xlab("cyl")
@sa-lee
sa-lee / run_structure_fromR.R
Created May 10, 2016 02:12
Running structure in R in parallel
library(parallel)
library(stringr)
# prelim setup
structure_binary <- "/path/to/structure"
n.cores <- 8
# number of Ks to try
tryK <- 1L:20L
n.runs <- 1L:20L