This file contains hidden or 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
# vector of net paid/owed, i.e., positive means owed money | |
b = c(Alice=-15, Bob=130, Charlie=-125, Diane=150, Ed=20, Frank=-160) | |
stopifnot(sum(b) == 0) | |
n = length(b) | |
m = n * (n - 1) / 2 | |
A = combn(n, 2, function(x) { | |
out = numeric(n) | |
out[x] = c(1, -1) | |
out |
This file contains hidden or 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(janitor) | |
library(rvest) | |
library(rstanarm) | |
library(posterior) | |
# load data, add 2024 candidates | |
page <- read_html("https://fivethirtyeight.com/features/trump-chances-to-win-republican-primary/") | |
d <- html_table(page) |> |
This file contains hidden or 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
#!/usr/bin/env bash | |
RSTUDIO=/Applications/RStudio.app/Contents | |
# find Quarto and give instructions for putting it and pandoc on the path | |
QUARTO_PATH=$(find $RSTUDIO -name "quarto" -type d | head -n 1) | |
echo 'Add the following to your $PATH:' | |
echo "PATH=\$PATH:$QUARTO_PATH/bin/" | |
echo "PATH=\$PATH:$QUARTO_PATH/bin/tools" |