Skip to content

Instantly share code, notes, and snippets.

View schochastics's full-sized avatar
👨‍💻

David Schoch schochastics

👨‍💻
View GitHub Profile
@schochastics
schochastics / get_squads.R
Created September 30, 2018 20:56
get squads from footballsquads.co.uk
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 August 24, 2018 21:21
scrape mean age and market values for European Football leagues
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")
@schochastics
schochastics / umap.R
Last active October 10, 2018 19:24
Quick and dirty way of using UMAP in R using rPyhton
#install UMAP from https://github.com/lmcinnes/umap
#install.packages("rPython")
umap <- function(x,n_neighbors=10,n_components=2,min_dist=0.1,metric="euclidean"){
x <- as.matrix(x)
colnames(x) <- NULL
rPython::python.exec( c( "def umap(data,n,d,mdist,metric):",
"\timport umap" ,
"\timport numpy",
"\tembedding = umap.UMAP(n_neighbors=n,n_components=d,min_dist=mdist,metric=metric).fit_transform(data)",
@schochastics
schochastics / sampleEntropy.cpp
Last active August 22, 2024 05:50
Calculate Sample Entropy in Rcpp
//MIT License
//Copyright (c) 2024 David Schoch
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
@schochastics
schochastics / beergarden.csv
Created January 19, 2018 15:19
Locations of beergardens around Munich
Name Biermarke Long Lat
Augustiner-Keller Augustiner 11.551223 48.14374
Aujäger Hacker Pschorr 11.44961 47.919287
Alte Villa Kaltenberger 11.098123 48.026349
Alter Wirt Krailling Augustiner 11.417515 48.098479
Alter Wirt Etterschlag Paulaner 11.200658 48.086221
Alter Wirt Moosach Hofbräu 11.51235 48.180948
Alter Wirt Ramersdorf Augustiner 11.614319 48.114996
Ayinger Ottobrunn Ayinger 11.6647398 48.0651976
Bergl Hacker Pschorr 11.567563 48.260538
@schochastics
schochastics / storms.R
Created September 5, 2017 11:36
replication of u/Tjukanov's post in r/dataisbeautiful in R
################################################################################
# replication of https://i.redd.it/q0udc4wfhvjz.gif
# originally posted to r/dataisbeautiful by u/Tjukanov
################################################################################
library(tidyverse)
library(gganimate)
library(lubridate)
#data from: https://www.ncdc.noaa.gov/ibtracs/index.php?name=wmo-data
df <- read_csv("Allstorms.ibtracs_wmo.v03r09.csv")