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(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 |
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(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) |
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(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 | |
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(dplyr) | |
library(tidyr) | |
library(ggplot2) | |
library(ggthemes) | |
library(scales) | |
library(lubridate) | |
library(rvest) | |
system_time= paste("Update: ", Sys.time()) | |
txt_data <- " | |
dhb, pop12+,dosed2 |
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
# 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" |
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
# 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" |
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
davidise_graph <- function(x, savepath="~/Desktop/output", show_graph = TRUE){ | |
# x is an unthemed ggplot graph but all the scales & labs are applied | |
# since this function wants a ggplot graph, I am assuming ggplot is loaded) | |
# assume Open Sans installed as a font | |
library(showtext) | |
# sort out your own font path declarations | |
font_add(family = "OpenSans", regular = "~/Library/Fonts/OpenSans-Light.ttf", | |
bolditalic = "~/Library/Fonts/OpenSans-BoldItalic.ttf", | |
italic = "~/Library/Fonts/OpenSans-LightItalic.ttf", |
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
# Data | |
# 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) | |
library(patchwork) | |
# you need to provide csv name |
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(rtweet) | |
library(dplyr) | |
library(lubridate) | |
library(ggplot2) | |
library(tidytext) | |
library(topicmodels) | |
search_term <- "#nzpol" | |
corpus <- search_tweets(search_term, n=18000) | |
nzpol_utm <- corpus %>% select(screen_name, text) %>% | |
unnest_tokens(word,text, token="tweets") %>% |