Skip to content

Instantly share code, notes, and snippets.

library(rvest)
library(readr)
library(dplyr)
library(tidyr)
library(lubridate)
#######
# assuming the DHB subnational population file downloaded
# and cached in the working directory from
# https://figure.nz/table/vEnTmdKKixC0HrEF
Date Category Unvaxed partvaxed fullvaxed under12 ChangeUn Change2 Pop2 Pop1 PopU Unv100K Two100K ThreeDayU ThreeDay2
2021-11-27 Cases 3404 1661 1080 1830
2021-11-28 Cases 3449 1681 1112 1876 45 32
2021-11-29 Cases 3491 1711 1158 1938 42 46
2021-11-30 Cases 3518 1737 1194 1982 27 36
2021-12-01 Cases 3563 1759 1223 2029 45 29
2021-12-02 Cases 3623 1786 1266 2070 60 43
2021-12-03 Cases 3651 1812 1290 2083 28 24
2021-12-04 Cases 3677 1832 1317 2105 26 27
2021-12-05 Cases 3703 1855 1348 2131 26 31
library(readr)
library(dplyr)
library(lubridate)
library(RcppRoll)
library(ggplot2)
library(ggthemes)
library(sf)
library(rmapshaper)
library(tidyr)
library(patchwork)
@thoughtfulbloke
thoughtfulbloke / Convert_Wordle_Share_to_Image_with_alt_text.R
Last active January 17, 2022 08:04
converts wordle share to an image and autogenerates accompanying alt text
library(ggplot2)
library(ggthemes)
library(dplyr)
colour_choice <- colorblind_pal()(3)
pasted_text = "PasteYourGameShareHre"
pasted_title <- gsub("\n\n.*", "", pasted_text)
title_short <- substr(pasted_title, 1, nchar(pasted_title) - 4)
pasted_grid <- gsub(".*[^/ ]/[^\\\n]+", "", pasted_text)
@thoughtfulbloke
thoughtfulbloke / MiQnumbers.R
Last active January 11, 2022 00:29
graph of positive covid cases in MiQ
library(rvest)
library(dplyr)
library(lubridate)
library(readr)
library(ggplot2)
library(ggthemes)
library(ggridges)
source("davidise.R")
# saving reports from the website as html into a folder
# called news_item_html
@thoughtfulbloke
thoughtfulbloke / omicron.R
Created January 1, 2022 04:01
Code for showing no community spread of omicron at present
library(readr)
library(dplyr)
library(ggplot2)
library(ggthemes)
library(lubridate)
source("davidise.R") # graph styling and saving at twitter size
# extract colorblind pallete in case I want to make strategic use of it
six_cols <- (colorblind_pal()(6))
# daily full demographic csvs folder
cases_folder <- list.files("daily_all_cases", pattern = "csv$", full.names = TRUE)
@thoughtfulbloke
thoughtfulbloke / locad.R
Created November 3, 2021 22:12
rolling locations of interest per adult case of covid
library(dplyr)
library(lubridate)
library(ggplot2)
library(ggthemes)
library(tidyr)
library(RcppRoll)
# To look at locations of interest, I am taking my own set of infectious vs isolated cases from the 1pm news conference, the csv of individual case details to get location (available as a csv linked from https://www.health.govt.nz/our-work/diseases-and-conditions/covid-19-novel-coronavirus/covid-19-data-and-statistics/covid-19-case-demographics ), and a collection of the location of interest updates kindly provided by @nzgizmoguy on Twitter at https://github.com/gizmoguy/locations-of-interest
@thoughtfulbloke
thoughtfulbloke / vaxday.R
Last active October 16, 2021 03:09
vaxathon progress code
library(dplyr)
library(tidyr)
library(ggplot2)
library(ggthemes)
library(scales)
library(lubridate)
library(rvest)
system_time= paste("Update: ", Sys.time())
txt_data <- "
dhb, pop12+,dosed2
@thoughtfulbloke
thoughtfulbloke / OECDmortRate.R
Created September 17, 2021 04:07
calculating weekly mortality rates from the OECD data source
# OECD weekly all cause deaths to mortality rates
# Keep in mind, some countries (Sweden) exclude 3% of deaths from the weekly
# dataset as the day of death is not known
library(OECD)
library(dplyr)
country1 = "NZL"
country2 = "USA"
@thoughtfulbloke
thoughtfulbloke / lockdownvsCases.R
Created September 14, 2021 05:07
R code for graph showing NZ lockdown vs. Cases
# MoH is the ministry of Health all cases demographics csv file
# https://www.health.govt.nz/our-work/diseases-and-conditions/covid-19-novel-coronavirus/covid-19-data-and-statistics/covid-19-case-demographics#case-details
library(readr)
library(dplyr)
library(ggplot2)
library(ggthemes)
library(lubridate)
# you need to provide csv name
file_name <- "covid_cases_2021-09-14.csv"