Skip to content

Instantly share code, notes, and snippets.

View charliejhadley's full-sized avatar
🙋‍♀️
All tech is political

Charlie Joey Hadley charliejhadley

🙋‍♀️
All tech is political
View GitHub Profile
@charliejhadley
charliejhadley / bechdel-chart.R
Created April 13, 2024 17:43
bechdel-chart.R
library("tidyverse")
library("fivethirtyeight")
library("ggrepel")
library("hrbrthemes")
library("ggtext")
bechdel_complete <- bechdel %>%
drop_na() %>%
mutate(profitable = budget_2013 <= domgross_2013)
@charliejhadley
charliejhadley / starwars-graph.R
Created February 11, 2024 13:41
starwars-graph.R
library(tidyverse)
library(ggraph)
library(tidygraph)
nodes_characters <- starwars %>%
mutate(character_id = row_number(), .before = 0) %>%
mutate(across(where(is.list), ~lengths(.x), .names = "n_{.col}"))
edges_reoccuring_co_stars <- nodes_characters %>%
@charliejhadley
charliejhadley / births-deaths.csv
Created January 19, 2024 12:06
births-deaths.csv
We can make this file beautiful and searchable if this error is corrected: Illegal quoting in line 3.
tibble::tribble(
~country, ~year, ~month, ~name, ~value,
"Australia", 2011L, "January", "births", 24550L,
"Australia", 2011L, "January", "deaths", 11483L,
"Australia", 2011L, "February", "births", 23209L,
"Australia", 2011L, "February", "deaths", 10522L
)
function(input, output, session){
output$curve_plot <- renderPlot({
print(input$exponent)
curve(x^as.integer(input$exponent), from = -5, to = 5)
@charliejhadley
charliejhadley / get_docs_rdocsanalysis.R
Created April 1, 2023 13:53
get_docs_rdocsanalysis.R
devtools::install_github("charliejhadley/rdocsanalysis")
library(tidyverse)
dplyr_docs <- rdocsanalysis::process_pkg_docs("dplyr", version_number = "1.0.0")
@charliejhadley
charliejhadley / funky-data.csv
Created March 21, 2023 19:03
Week 3 Assignment
date_quote date_purchase flag
2020-08-15 2020-09-28 TRUE
2020-07-27 2020-09-09 FALSE
2020-07-22 2020/09/04 FALSE
2020-08-22 2020-10-05 TRUE
2020-04-14 2020-05-28 TRUE
2020-05-27 2020/07/10 TRUE
2020-03-20 2020-05-03 FALSE
2020-03-15 2020/04/28 FALSE
2020-01-12 2020/02/25 FALSE
library(tigris)
library(sf)
library(rmapshaper)
library(readxl)
library(janitor)
library(leaflet)
library(tidyverse)
# ==== Streaming Data ====
# Data obtained from https://kiss951.com/2021/05/20/national-streaming-day-list-of-the-most-popular-streaming-services-in-each-state/
@charliejhadley
charliejhadley / waterfall-chart.R
Created October 13, 2022 20:06
waterfall-chart
library(tidyverse)
data_waterfall_raw <- read_csv("waterfall.csv")
data_waterfall_clean <- data_waterfall_raw %>%
mutate(order = row_number()) %>%
mutate(event = str_wrap(event, 12)) %>%
mutate(event = fct_reorder(event, order)) %>%
mutate(
end = cumsum(change),
@charliejhadley
charliejhadley / mortgate-rate.R
Last active October 3, 2022 18:48
mortgate-rate.R
library(tidyverse)
library(lubridate)
library(bbplot)
library(ggtext)
# values for five-year mortgages are inaccurately read from the original graphic by BBC
# https://twitter.com/charliejhadley/status/1576992785638772736?s=20&t=DTM3oBSGAsSOQ2SIrvUB-A
mortgage_rates <- tribble(
~date, ~rate, ~deal,
@charliejhadley
charliejhadley / quarto.qmd
Created September 30, 2022 09:51
rmd-vs-quarto
---
title: "Quarto"
format: html
echo: false
message: false
warning: false
---
```{r load-packages}
library(tidyverse)