Skip to content

Instantly share code, notes, and snippets.

View ojessen's full-sized avatar

Owe Jessen ojessen

View GitHub Profile
@ojessen
ojessen / gist:a0719086fce8081547f20b024c7a4fdc
Created April 14, 2017 21:33
Scraping NBA results and plotting them
library(rvest)
library(dplyr)
library(stringr)
base_url = "http://www.basketball-reference.com/play-index/tscore.cgi?request=1&match=combined&"
post_fix_1 = "is_playoffs=N&order_by=pts"
post_fix_rest = "year_min=1955&year_max=2017&team_id=&opp_id=&quarter_is_1=&quarter_is_2=&quarter_is_3=&quarter_is_4=&quarter_is_5=&is_playoffs=N&round_id=&game_num_type=&game_num_min=&game_num_max=&game_month=&game_location=&game_result=&is_overtime=&c1stat=&c1comp=&c1val=&c2stat=&c2comp=&c2val=&c3stat=&c3comp=&c3val=&order_by=pts&order_by_asc=&offset="
vec_url = c(paste0(base_url, post_fix_1),
paste0(base_url, post_fix_rest, seq(from = 100, to = 110000, by = 100)))
# Based on the Gist by @hrbrmstr https://gist.github.com/hrbrmstr/b91752d32a07ee8595db33babe735b6b
library(httr)
library(leaflet)
GET("https://ipinfo.io/json") %>% # get IP geolocated coordinates
content() %>%
.$loc %>%
strsplit(",") %>%
.[[1]] %>%
as.numeric() -> lat_lng
@ojessen
ojessen / Histogram_animation.R
Created June 15, 2016 05:41 — forked from thomasp85/Histogram_animation.R
An example of animating the build up of a histogram with dropping balls using tweenr, gganimate and ggplot2
library(tweenr) # Available on CRAN
library(ggforce) # Install from thomasp85/ggforce
library(gganimate) # Install from dgrtwo/gganimate
set.seed(2)
x <- sample(9,20, prob=c(1,2,3,4,5,4,3,2,1), replace=T)
df <- data.frame(x = x, y = 15)
dfs <- list(df)
for(i in seq_len(nrow(df))) {
dftemp <- tail(dfs, 1)
dftemp[[1]]$y[i] <- sum(dftemp[[1]]$x[seq_len(i)] == dftemp[[1]]$x[i])
@ojessen
ojessen / Delegated Acts
Last active August 29, 2015 14:07
Diff Solvency II Delegated Acts
D14B3609D1A4497B88117CE30425F20E
EXPLANATORY MEMORANDUM
1. CONTEXT OF THE DELEGATED ACT
1.1 General background and objectives
@ojessen
ojessen / build_r_bamboo.sh
Created January 29, 2014 16:23
Shell script for building an R skript on Atlassian Bamboo
# Adjusted bash for building in Atlassian Bamboo
#
# See README.md for instructions, or for more configuration options,
# see the wiki:
# https://github.com/craigcitro/r-travis/wiki
curl -OL http://raw.github.com/craigcitro/r-travis/master/scripts/travis-tool.sh
chmod 755 ./travis-tool.sh
./travis-tool.sh bootstrap
./travis-tool.sh install_deps
@ojessen
ojessen / passwd_prototype.R
Created January 27, 2014 20:30
Protoype password handling with hash
require(digest)
require(shiny)
ui <- basicPage(
uiOutput("register"),
actionButton("doRegister",label="Register"),
verbatimTextOutput("resultRegister"),
uiOutput("login"),
@ojessen
ojessen / gist:8604593
Last active January 4, 2016 09:49
Testing NumericInput
require(shiny)
ui <- basicPage(
numericInput("test", "Input Number", value=2, min=0, max=5),
verbatimTextOutput("test_regression"),
tableOutput("session_info"),
tableOutput("shiny_info"),
verbatimTextOutput("test_alpha"),
tableOutput("test_df")