Skip to content

Instantly share code, notes, and snippets.

function colors = pal_hue(n, s, v)
% Generates a palette of n evenly spaced colors with default settings
% similar to R's scales::pal_hue().
% s is the saturation (default 0.75), v is the value (brightness, default 0.95).
% The hue component varies from 0 to 1.
if nargin < 2
s = 0.75; % Default saturation
end
if nargin < 3
@seankross
seankross / README.md
Last active April 28, 2023 16:55
Get TTS working in R with Reticulate on M1 or M2 MacOS

Make sure homebrew is all up to date.

Make sure you have venv working, I think it just comes with python3.

Start a brand new RStudio project and open it in RStudio.

In the terminal:

python -m venv .venv
@seankross
seankross / jazz.txt
Created May 18, 2018 18:20
Jazz Toni Morrison
From "Jazz" by Toni Morrison
It's nice when grown people whisper to each other under the covers. Their
ecstasy is more leaf-sigh than bray and the body is the vehicle, not the point.
They reach, grown people, for something beyond, way beyond and way, way down
underneath tissue. They are remembering while they whisper the carnival dolls
they won and the Baltimore boats they never sailed on. The pears they let hang
on the limb because if they plucked them, they would be gone from there and who
else would see that ripeness if they took it away for themselves? How could
anybody passing by see them and imagine for themselves what the flavor would
@seankross
seankross / schools.R
Created March 29, 2018 19:08
Graph for Clare
# You can find pch values for shapes here:
# https://cdn-images-1.medium.com/max/1600/1*0QEVFHrgqmkVsCVCQceh6w.jpeg
data <- data.frame(
Name = c("Ohio State", "Purdue", "Indiana", "Wisconsin", "Nebreaska"),
Min = c(0.37, 0.25, 0.13, 0.22, 0.28),
Max = c(0.88, 0.57, 0.68, 0.77, 0.63),
Value = c(0.51, 0.32, 0.24, 0.65, 0.57),
Pch = c(1, 2, 5, 6, 22),
stringsAsFactors = FALSE
@seankross
seankross / emilyp.R
Created March 7, 2018 04:04
Getting p-values out of a model, two ways
berkeley <- as.data.frame(UCBAdmissions)
model <- glm(Admit ~ Gender + Dept + Freq, data = berkeley, family = "binomial")
# Base R
model_summary <- summary(model)
model_summary$coefficients[,4]
# Or become one of the cool kids
library(shiny)
library(miniUI)
ui <- miniPage(
gadgetTitleBar("My Gadget"),
miniContentPanel(
## Your UI items go here.
)
)
library(dplyr)
c(2, 5, 6) %>% sum()
cars_i_want <- mtcars %>%
filter(mpg > 20) %>%
filter(cyl == 4) %>%
arrange(hp)
mtcars %>%
@seankross
seankross / expected.R
Created September 22, 2017 20:33
For Stephan
steph <- structure(c(148L, 65L, 198L, 53L, 16L, 2004L), .Dim = c(3L, 2L
), .Dimnames = structure(list(c("EatNoTrans", "Request", "Stealing"
), c("0", "1")), .Names = c("", "")), class = "table")
chisq_steph <- chisq.test(steph)
chisq_steph$expected
@seankross
seankross / install_ffmpeg_ubuntu.sh
Last active May 14, 2020 16:48 — forked from xdamman/install_ffmpeg_ubuntu.sh
Install latest ffmpeg on ubuntu 12.04 or 14.04
#!/bin/bash
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04
# Inspired from https://gist.github.com/faleev/3435377
# Remove any existing packages:
sudo apt-get -y remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
# Get the dependencies (Ubuntu Server or headless users):
sudo apt-get update
library(dplyr)
library(purrr)
set.seed(2017-06-27)
# Imagine this function gives us measurements from nature
data_generator <- function(n = 500){
data_frame(var1 = rnorm(500)) %>%
mutate(var2 = var1 + rnorm(500)) %>%
mutate(var3 = var1 * var2 + rnorm(500)) %>%