This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script takes the scraped IBA cocktails dataset found here: | |
# https://github.com/rasmusab/iba-cocktails | |
# And produces a four page PDF with all the IBA cocktails and animated GIFs that | |
# loops through these, as well. | |
library(tidyverse) | |
library(glue) | |
library(ggtext) | |
library(gridExtra) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bowling_animation_urls <- c( | |
"0.01" = "https://i.imgur.com/Kn8CQbj.gif", | |
"0.05" = "https://i.imgur.com/HFTKdDL.gif", | |
"0.1" = "https://i.imgur.com/8Sw54Mz.gif", | |
"1" = "https://i.imgur.com/kjROdhj.gif" | |
) | |
# We need to download the animations to the session temp dirercorty to display | |
# them in the Rstudio Viever pane | |
bowling_animation_html <- sapply(bowling_animation_urls, function(url) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to call the new (as of 2023-03-01) ChatGTP API from R | |
# Get your API key over here: https://platform.openai.com/ | |
api_key <- "sk-5-your-actual-api-key-Fvau6" # Don't share this! 😅 | |
library(httr) | |
library(stringr) | |
# Calls the ChatGTP API with the given promps and returns the answer | |
ask_chatgtp <- function(prompt) { | |
response <- POST( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prior to the tutorial make sure that the script below runs without error on your R installation. | |
# What you need is a working installation of JAGS: http://mcmc-jags.sourceforge.net/ | |
# and the rjags R package that can be installed from R by running | |
# install.packages("rjags") | |
# Generating some fake data | |
set.seed(123) | |
y <- rbinom(30, size = 1, prob = 0.2015) | |
# Fitting a simple binomial model using JAGS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | Name | Type 1 | Type 2 | Total | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Generation | Legendary | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Bulbasaur | Grass | Poison | 318 | 45 | 49 | 49 | 65 | 65 | 45 | 1 | False | |
2 | Ivysaur | Grass | Poison | 405 | 60 | 62 | 63 | 80 | 80 | 60 | 1 | False | |
3 | Venusaur | Grass | Poison | 525 | 80 | 82 | 83 | 100 | 100 | 80 | 1 | False | |
3 | VenusaurMega Venusaur | Grass | Poison | 625 | 80 | 100 | 123 | 122 | 120 | 80 | 1 | False | |
4 | Charmander | Fire | 309 | 39 | 52 | 43 | 60 | 50 | 65 | 1 | False | ||
5 | Charmeleon | Fire | 405 | 58 | 64 | 58 | 80 | 65 | 80 | 1 | False | ||
6 | Charizard | Fire | Flying | 534 | 78 | 84 | 78 | 109 | 85 | 100 | 1 | False | |
6 | CharizardMega Charizard X | Fire | Dragon | 634 | 78 | 130 | 111 | 130 | 85 | 100 | 1 | False | |
6 | CharizardMega Charizard Y | Fire | Flying | 634 | 78 | 104 | 78 | 159 | 115 | 100 | 1 | False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(purrr) | |
library(rstan) | |
### Defining the data ### | |
######################### | |
bumblebees <- c(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, | |
0, 0, 1, 0, 0, 0, 0, 0, 0) | |
toddler_steps <- c(26, 16, 37, 101, 12, 122, 90, 55, 56, 39, 55, 15, 45, 8) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rjags) | |
library(mvtnorm) # to generate correlated data with rmvnorm. | |
library(car) # To plot the estimated bivariate normal distribution. | |
set.seed(31415) | |
mu <- c(10, 30) | |
sigma <- c(20, 40) | |
rho <- -0.7 | |
cov_mat <- rbind(c( sigma[1]^2 , sigma[1]*sigma[2]*rho ), | |
c( sigma[1]*sigma[2]*rho, sigma[2]^2 )) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prior to the tutorial make sure that the script below runs without error on your R installation. | |
# What you need is a working installation of Stan: http://mc-stan.org/ . | |
# For installation instructions, see here: | |
# https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started | |
# After installation you should be able to run this script which should output | |
# some summary statistics and some pretty plots, :) | |
# Generating some fake data | |
set.seed(123) |
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 4.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
NewerOlder