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(tidyverse) | |
library(ggwordcloud) | |
library(tidytext) | |
# https://github.com/lepennec/ggwordcloud | |
# https://cran.r-project.org/web/packages/tidytext/vignettes/tidytext.html | |
# get some text, remove newline/return chars | |
text <- read_file("https://www.gutenberg.org/cache/epub/84/pg84.txt") |> | |
str_replace_all(pattern = "\r\n|\n|\r", replacement = " ") |> |
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(tidyverse) | |
library(jsonlite) | |
library(leaflet) | |
library(raster) | |
library(terra) | |
library(htmlwidgets) | |
library(htmltools) | |
# https://www.swpc.noaa.gov/products/aurora-30-minute-forecast |
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(tidyverse) | |
library(janitor) | |
library(lubridate) | |
library(zoo) | |
library(ckanr) | |
# generates age/sex population lookup for Scotland based on NRS mid-year | |
# population estimates/projections, interpolated linearly to day level | |
# (July 2nd used as mid-year reference date). | |
# |
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(tidyverse) | |
library(janitor) | |
library(lubridate) | |
library(zoo) | |
library(ckanr) | |
# generates age/sex population lookup for Scotland based on NRS mid-year | |
# population estimates/projections, interpolated linearly to day level | |
# (July 2nd used as mid-year ref date) |
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(openair) | |
library(tidyverse) | |
library(lubridate) | |
#### SETUP #### | |
saqn_meta <- importMeta(source = "SAQN", all = TRUE) # metadata for all the Scottish Air Quality Network sites | |
years <- 1987:2019 # NO2 trend goes back to 1987 for Glasgow City Chambers | |
glasgow_saqn_sites_pm10 <- c("Glasgow Abercromby Street", | |
"Glasgow Anderston", |
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(tidyverse) | |
library(stats19) | |
library(ckanr) | |
# libs for mapping accident lat/long to datazone for Glasgow deprivation analysis | |
library(sf) | |
library(rmapshaper) | |
# below libs useful for speeding up mapping accidents over water to nearest datazone | |
library(foreach) | |
library(doParallel) | |
registerDoParallel(parallel::detectCores()) |
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
xmas_gifts <- function(days=12, pear_tree=FALSE){ | |
days <- abs(as.integer(days)) | |
gifts <- 0 | |
# for(i in 1:days){gifts <- gifts + i*(days + 1 - i)} # general case: does N=days total summations | |
# can ~half the number of summations because... | |
# if days = even, summation is symmetric and reduces to e.g. 2*[12x1 + 11x2 + 10x3 + 9x4 + 8x5 + 7x6] for 12 total days | |
for(i in 1:(days/2 - .5* days %% 2)){ |
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
# remotes::install_github("tylermorganwall/rayshader") | |
library(rayshader) # rayshader_0.11.4 | |
library(ggplot2) | |
library(sf) | |
library(tidyverse) | |
library(rmapshaper) | |
library(viridis) | |
#### DATA IMPORT #### | |
# inpatient numbers, by health board, Oct-Dec 2018 |
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(tidyverse) | |
library(ggplot2) | |
library(survival) | |
lambdas <- seq(300, 2) | |
pic_dir <- "pics" | |
fps <- 24 | |
output_video <- "output.mp4" | |
# construct dataframes |
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(Rcpp) | |
library(ggplot2) | |
library(dplyr) | |
library(foreach) | |
library(doParallel) | |
registerDoParallel(parallel::detectCores()) | |
pic_dir <- "pics" | |
output_video <- "output.mp4" |
NewerOlder