Skip to content

Instantly share code, notes, and snippets.

View tanho63's full-sized avatar
๐Ÿˆ

Tan Ho tanho63

๐Ÿˆ
View GitHub Profile
@tanho63
tanho63 / fivethirtyeight_footer.R
Created November 13, 2023 17:49
Fivethirtyeight footer
@tanho63
tanho63 / rb_situation_usage.R
Last active September 29, 2023 18:20
rb situation usage plot
rb_opps <- data.table::rbindlist(
list(
nflreadr::load_ff_opportunity(stat_type = "pbp_rush"),
nflreadr::load_ff_opportunity(stat_type = "pbp_pass")
),
fill = TRUE) |>
dplyr::filter(position == "RB" | receiver_position == "RB", week == 3, posteam == "MIA") |>
dplyr::transmute(
game_id,
player_name = dplyr::coalesce(receiver_full_name, full_name),
library(yaml)
url_tag <- "<a href='http://my-url.com'>My website</a>"
quoted <- function(x){
attr(x, "quoted") <- TRUE
return(x)
}
list(x = quoted(url_tag)) |> yaml::as.yaml()
# Gist URL https://gist.github.com/e194fa3e10d9e85fdedae6318e688557
library(yaml)
url_tag <- "<a href='http://my-url.com'>My website</a>"
attr(url_tag,"quoted") <- TRUE
list(x = url_tag) |> yaml::as.yaml()
# Gist URL https://gist.github.com/4d3ce5f22b53ebad6ed472653b700171
library(yaml)
url_tag <- "<a href='http://my-url.com'>My website</a>"
attr(url_tag,"quoted") <- TRUE
list(x = url_tag) |> yaml::as.yaml()
# Gist URL https://gist.github.com/b8ba7b2c3a3578ac19737882fef7dbea
@tanho63
tanho63 / mlb_videos.R
Created March 23, 2022 15:46
Downloading videos from MLB API with R
# All base R actually but make sure libcurl is installed if you're on Linux
# Devtools -> Copy as cURL -> go to curlconverter.com/#r and paste -> mostly important to get headers in this case
# idk which of these work but this combo works
headers = c(
`User-Agent` = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:98.0) Gecko/20100101 Firefox/98.0',
`Accept` = '*/*',
`Accept-Language` = 'en-US,en;q=0.5',
`Accept-Encoding` = 'gzip, deflate, br',
`Origin` = 'https://www.mlb.com',
`DNT` = '1',
@tanho63
tanho63 / tenthousandpeople.R
Created January 2, 2022 03:26
Genuary 2022.01 - Ten Thousand People
library(ggplot2)
library(ragg)
library(systemfonts)
library(tantastic) # tanho63/tantastic
library(tidyverse)
# Weepeople font https://github.com/propublica/weepeople/
colours <- c("#5E4AE3","#44FFD1","#EFCA08","#FF3366")
crossing(
@tanho63
tanho63 / scrape_stream_notes.md
Last active July 22, 2021 00:58
scraping stream questions
@tanho63
tanho63 / scoobydoo_pivot.R
Last active September 25, 2023 19:19
pivot_longer sentinel .value - scoobydoo tidy tuesday
library(tidyverse)
scooby_data <- read.csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-07-13/scoobydoo.csv")
x <-
scooby_data %>%
select(season, title,
starts_with("caught"),
starts_with("captured"),
starts_with("unmask"),
@tanho63
tanho63 / position-picker-input.R
Last active November 9, 2022 08:26
pickerInput example
positions <- data.frame(pos = c("QB","RB","WR","TE"),
posdesc = c("Quarterback","Running Back","Wide Receiver","Tight End"))
shinyWidgets::pickerInput(
inputId = 'positions',
label = 'position',
choices = positions$pos,
selected = positions$pos,
multiple = TRUE,
options = list(