Skip to content

Instantly share code, notes, and snippets.

View abresler's full-sized avatar

Alex Bresler abresler

View GitHub Profile
@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(
@DavisVaughan
DavisVaughan / tidygraph.r
Last active May 2, 2018 00:37
Exploring finanicial binomial recombining trees with tidygraph
# SCROLL TO THE GITHUB COMMENT BELOW FOR THE FULL OUTPUT WITH IMAGES
# COPY AND PASTE THIS FOR EASY ACCESS TO REPRODUCIBLE CODE
# ------------------------------------------------------------------------------
library(tidygraph)
library(ggraph)
library(dplyr)
library(igraph)
library(tibble)
@hrbrmstr
hrbrmstr / ageingpriestly.r
Created June 16, 2016 13:49
priestly timeline for FT blog post
library(ggplot2)
library(dplyr)
ft <- read.csv("ftpop.csv", stringsAsFactors=FALSE)
arrange(ft, start_year) %>%
mutate(country=factor(country, levels=c(" ", rev(country), " "))) -> ft
ft_labs <- data_frame(
x=c(1900, 1950, 2000, 2050, 1900, 1950, 2000, 2050),
@expersso
expersso / fed_locations.R
Last active June 10, 2016 15:11
Get locations of Federal Reserve Speeches
library(purrr)
library(dplyr)
library(rvest)
library(stringr)
library(geoparser)
w_msg <- function(f) {
force(f)
function(...) {
args <- list(...)
@expersso
expersso / pew.R
Created June 7, 2016 15:14
Income and demographics in U.S. metropolitan areas
read_sheet <- function(file, sheet) {
readxl::read_excel(file, sheet, skip = 6) %>% clean_data()
}
fix_names <- function(df) {
names(df)[1] <- "location"
names(df)[-1] <- paste(rep(c(2000, 2014), each = length(names(df)[-1]) / 2),
names(df)[-1], sep = "_")
df
}
library(jsonlite)
library(tigris)
library(ggplot2)
library(purrr)
library(tidyr)
library(dplyr)
library(sp)
library(rgeos)
library(rgdal)
library(maptools)
belief y2015 y2014
Improves the security posture of my organization 0.75 0.71
Improves the security posture of the nations critical infrastructure 0.63 0.64
Reduces the cost of detecting and preventing cyber attacks 0.22 0.21
Improves situational awareness 0.60 0.54
Fosters collaboration among peers and industry groups 0.48 0.51
Enhances the timeliness of threat data 0.11 0.16
Makes threat data more actionable 0.21 0.24
@rasmusab
rasmusab / probability_of_pregnancy.R
Created November 5, 2015 19:46
A script that implements a Bayesian model calculating the probability that a couple is fertile and is going to be pregnant.
# A Bayesian model that calculates a probability that a couple is fertile
# and pregnant. Please use this for fun only, not for any serious purpose
# like *actually* trying to figure out whether you are pregnant.
# Enter your own period onsets here:
period_onset <- as.Date(c("2014-07-02", "2014-08-02", "2014-08-29", "2014-09-25",
"2014-10-24", "2014-11-20", "2014-12-22", "2015-01-19"))
# If you have no dates you can just set days_between_periods to c() instead like:
# days_between_periods <- c()
days_between_periods <- as.numeric(diff(period_onset))
library(SmarterPoland)
library(riverplot)
library(RColorBrewer)
library(graphics)
library(reshape2)
library(plyr)
library(stringr)
library(countrycode)
# DOWNLOAD THE DATA
@rich-iannone
rich-iannone / diagrammer-fixed-nodes-visnetwork.R
Last active October 2, 2015 03:34
Fixed nodes (with specified positions) in DiagrammeR
# Installation
#install.packages("devtools")
devtools::install_github("rich-iannone/DiagrammeR")
library(DiagrammeR)
# Create and render an empty graph
empty_graph <- create_graph()
render_graph(empty_graph, output = "visNetwork")