Skip to content

Instantly share code, notes, and snippets.

View gsimchoni's full-sized avatar

Giora Simchoni gsimchoni

View GitHub Profile
@gsimchoni
gsimchoni / bechdel_538
Last active February 24, 2020 04:57
Trying to recreate 538 Bechdel Test plot
# plot is here: https://fivethirtyeight.com/features/the-dollar-and-cents-case-against-hollywoods-exclusion-of-women/
library(tidyverse)
library(fivethirtyeight)
library(lubridate)
library(scales)
extract_period <- function(year) {
period <- year - year %% 5
century <- year - year %% 100
@gsimchoni
gsimchoni / formulan.R
Last active September 28, 2018 23:55
Shiny app for making polynomial lines from hand drawings, to appear in giorasimchoni.com
library(shiny)
library(glmnet)
res_list <- list()
get_poly_coef <- function(x, y, max_degree = 5) {
if (length(x) < 20) {
warning('x length less than 20')
}
mm <- model.matrix(~ poly(x, degree = max_degree, raw = TRUE))[, -1]