Skip to content

Instantly share code, notes, and snippets.

David Schoch schochastics

Block or report user

Report or block schochastics

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View time_prediction.R
library(tidyverse)
library(ggforce)
d <- tibble(x = c(1, 6, 10, 23,18), xpred = c(4, 8, 11, 2,22), y = 1:5, id = factor(1:5))
n <- nrow(d)+1
time_angle <- tibble(hour=1:24,angle=0.25*60*hour)
d$start <- time_angle$angle[d$x]*pi/180
d$end <- time_angle$angle[d$xpred]*pi/180
d$r <- d$y
@schochastics
schochastics / lissajous.R
Last active Oct 22, 2019
animated lissajous curves
View lissajous.R
lissajou <- function(a,b,delta){
t <- seq(0,2*pi,0.01)
x <- sin(a*t+delta)
y <- sin(b*t)
tibble(x,y)
}
# setup parameters ----
n <- 7
params <- tibble(a=sample(1:10,n,replace = FALSE),
@schochastics
schochastics / ggpyramid.R
Created May 30, 2019
ugly 3D pyramid plot
View ggpyramid.R
pyramid <- function(ymax=5,mcol="#CD3333",xoffset=0){
f <- function(a,b,y){
(y-b)/a
}
a1 <- ymax/0.65
b1 <- 0
c1 <- -ymax/(1-0.65)
d1 <- -c1
a2 <- -ymax/(1-0.65)
@schochastics
schochastics / nba_scorer.R
Created Apr 10, 2019
Barchart Race of Top NBA Scorers
View nba_scorer.R
library(rvest)
library(tidyverse)
library(gganimate)
library(extrafont)
loadfonts()
get_season <- function(x){
url <- paste0("https://www.basketball-reference.com/leagues/NBA_",x,"_totals.html")
url %>%
read_html() %>%
@schochastics
schochastics / the_matrix.R
Created Apr 1, 2019
the matrix with gganimate
View the_matrix.R
library(tidyverse)
library(gganimate)
ascii <- c(";", ":", "!", "?", ".", "'", "\"", "(", ")", "[", "]", "{",
"}", "@", "*", "/", "\\", "&", "#", "%", "`", "^", "+", "<",
"=", ">", "|", "~", "$", "0", "1", "1", "10", "2", "2", "3",
"3", "4", "4", "5", "5", "6", "6", "7", "7", "8", "8", "9", "9",
"a", "a", "A", "b", "b", "B", "c", "c", "C", "d", "d", "D", "e",
"e", "E", "f", "f", "F", "g", "g", "G", "h", "h", "H", "i", "i",
"I", "j", "j", "J", "k", "k", "K", "l", "l", "L", "m", "m", "M",
"n", "n", "N", "o", "o", "O", "p", "p", "P", "q", "q", "Q", "r",
@schochastics
schochastics / formations.csv
Created Feb 25, 2019
Premier league formation
View formations.csv
id home away
1 3-2-2-2-1 4-2-2-1-1
1 P. Cech Vardy
1 Holding Okazaki
1 Monreal Albrighton
1 Kolasinac Mahrez
1 Elneny Ndidi
1 G. Xhaka M. James
1 Bellerin Fuchs
1 Oxlade-Chamberlain Maguire
@schochastics
schochastics / radial_grp_layout.R
Last active Feb 8, 2019
radial layout with groups
View radial_grp_layout.R
library(igraph)
library(smglr)
library(tidyverse)
library(ggraph)
g <- sample_islands(9,40,0.2,10)
g <- simplify(g)
V(g)$grp <- rep(1:9,each=40)
el <- get.edgelist(g)
E(g)$col <- case_when(
V(g)$grp[el[,1]]==1 & V(g)$grp[el[,2]] == 1 ~ 1,
View theorem_graphs.R
library(rvest)
library(tidyverse)
# helper functions
get_theo_refs_cache <- function(url){
doc <- read_html(url)
caps <- doc %>% html_nodes("caption") %>% html_text()
skippy <- (any(caps=="Hypothesis" | caps=="Hypotheses"))+0
refs <- doc %>%
html_table() %>%
@schochastics
schochastics / get_squads.R
Created Sep 30, 2018
get squads from footballsquads.co.uk
View get_squads.R
library(rvest)
library(tidyverse)
leagues <- "http://www.footballsquads.co.uk/archive.htm" %>%
read_html() %>%
html_nodes("a") %>%
html_attr("href")
leagues_tbl <- as_tibble(str_split(leagues,"/",simplify = T)) %>%
mutate(link=leagues) %>%
@schochastics
schochastics / age_vs_value.R
Created Aug 24, 2018
scrape mean age and market values for European Football leagues
View age_vs_value.R
library(tidyverse)
library(rvest)
library(ggimage)
library(lubridate)
#get first 25 leagues in Europe ----
url <- "https://www.transfermarkt.de/wettbewerbe/europa"
doc <- read_html(url)
leagues <- doc %>% html_nodes(".hauptlink a") %>% html_attr("href")
You can’t perform that action at this time.