Skip to content

Instantly share code, notes, and snippets.

Avatar

Rasmus Bååth rasmusab

View GitHub Profile
@rasmusab
rasmusab / nobel.csv
Created Nov 5, 2020
Table with all Nobel prize winners from 1901 to 2020
View nobel.csv
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 4.
year,category,prize,motivation,prize_share,laureate_id,laureate_type,full_name,birth_date,birth_city,birth_country,gender,organization_name,organization_city,organization_country,death_date,death_city,death_country
1901,Chemistry,The Nobel Prize in Chemistry 1901,in recognition of the extraordinary services he has rendered by the discovery of the laws of chemical dynamics and osmotic pressure in solutions,1/1,160,Individual,Jacobus H. van 't Hoff,1852-08-30,Rotterdam,the Netherlands,male,Berlin University,Berlin,Germany,1911-03-01,Berlin,Germany
1901,Literature,The Nobel Prize in Literature 1901,"in special recognition of his poetic composition, which gives evidence of lofty idealism, artistic perfection and a rare combination of the qualities of both heart and intellect",1/1,569,Individual,Sully Prudhomme,1839-03-16,Paris,France,male,NA,NA,NA,1907-09-07,Châtenay,France
1901,Medicin,The Nobel Prize in Physiology or Medicine 1901,"for his work on serum therapy, especially its application against diphtheria, b
@rasmusab
rasmusab / get_nobel_data.R
Created Nov 5, 2020
This script pulls down information on all Nobel prize winners
View get_nobel_data.R
# This R script pulls down information on all Nobel prize winners
# from the official Nobel Prize API and selects a subset of this
# information that is then saves to a CSV-file.
# By Rasmus Bååth, 2020, in the public domain.
library(tidyverse)
library(httr)
nobel_response <- GET("http://api.nobelprize.org/2.0/laureates?limit=100000&format=json")
nobel_raw <- as_tibble(content(nobel_response, simplifyVector = TRUE, flatten = TRUE)$laureates)
@rasmusab
rasmusab / tidyverse_in_a_table.R
Last active Oct 30, 2020
The tidyverse documentation into a DT table
View tidyverse_in_a_table.R
library(DT)
library(glue)
library(tidyverse)
package_names <- tidyverse:::core
tidyverse_functions <- map_dfr(package_names, function(package_name) {
tibble(
Package = package_name,
Function = as.character(lsf.str(glue("package:{Package}"))),
@rasmusab
rasmusab / bayescamp_get_up_to_speed_with_bayes_test_script.R
Created Nov 21, 2019
BayesCamp 2019 tutorial - Get up to speed with Bayes test script
View bayescamp_get_up_to_speed_with_bayes_test_script.R
# Prior to the tutorial make sure that the script below runs without error on your R installation.
# You first need to install the following packages:
# install.packages(c("rstanarm", "prophet", "CausalImpact", "rstan"))
library(rstanarm)
library(prophet)
library(CausalImpact)
library(rstan)
library(ggridges)
@rasmusab
rasmusab / org.apache.arrow.vector.util.OversizedAllocationException_spark_error.txt
Created Oct 7, 2019
A long spark error: org.apache.arrow.vector.util.OversizedAllocationException
View org.apache.arrow.vector.util.OversizedAllocationException_spark_error.txt
---------------------------------------------------------------------------
Py4JJavaError Traceback (most recent call last)
in
----> 1 device_attack_result.count()
2
3
4
/usr/lib/spark/python/pyspark/sql/dataframe.py in count(self)
520 2
@rasmusab
rasmusab / groggbloggen_2015-2019.csv
Created Jun 29, 2019
Daily page views from groggbloggen.se 2015 to mid 2019
View groggbloggen_2015-2019.csv
date pageviews
2015-01-01 13
2015-01-02 27
2015-01-03 56
2015-01-04 18
2015-01-05 18
2015-01-06 8
2015-01-07 19
2015-01-08 32
2015-01-09 45
@rasmusab
rasmusab / get_up_to_speed_with_bayes_test_script.R
Last active Jul 8, 2019
UseR 2019 tutorial - Get up to speed with Bayes test script
View get_up_to_speed_with_bayes_test_script.R
# Prior to the tutorial make sure that the script below runs without error on your R installation.
# You first need to install the follwoing packages:
# install.packages(c("rstanarm", "prophet", "CausalImpact"))
library(rstanarm)
library(prophet)
library(CausalImpact)
# This will test that rstanarm works
# Don't be alarmed if you get a warning about "divergent transitions "
@rasmusab
rasmusab / analyze_gnubg.R
Created Jul 4, 2018
A barely tested R script that takes a backgammon match in any format gnubg can read, analyzes the match and returns a data frame with the analysis
View analyze_gnubg.R
# A barely tested R script that takes a backgammon match in any format
# gnubg can read, analyzes the match and returns a data frame with the analysis
# It requires that gnubg is readily available on the command line.
library(tidyverse)
library(jsonlite)
library(glue)
analyze_bg_match <- function(match_fname, match_format = "auto") {
gnubg_analysis_fname = tempfile()
@rasmusab
rasmusab / ab_test.csv
Created Jun 7, 2018
Example ab-test data
View ab_test.csv
date group n_purchases
2017-05-01 0 124
2017-05-02 0 95
2017-05-03 0 147
2017-05-04 0 116
2017-05-05 0 219
2017-05-06 0 248
2017-05-07 0 132
2017-05-08 0 110
2017-05-09 0 114
View monthly_deaths.csv
date births deaths
1841-01-01 254 37
1841-02-01 239 18
1841-03-01 277 12
1841-04-01 255 4
1841-05-01 255 2
1841-06-01 200 10
1841-07-01 190 16
1841-08-01 222 3
1841-09-01 213 4