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
##################################################### | |
# CLUSTER WORKFLOW # | |
##################################################### | |
#' This is a customised workflow for performing cluster analysis | |
#' under the following conditions: | |
#' - Mixed Data Type. | |
#' | |
#' How it works: | |
#' 1. Reads in an R data file eg. .RDS |
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
nthdayofmonth <- function(year, month, day, nth = 1){ | |
#' Finds the nth weekday of a given month and year | |
#' | |
#' Enter the year or years, month, and weekday along with the nth | |
#' weekday of the month you are interested in. | |
#' | |
#' @param year Character Vector. Year/s of interest | |
#' @param month Character. The numeric month i.e. "11" for November | |
#' @param day Character. The full weekday of interest, will do partial | |
#' matching. |
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
beta_plot <- function(shape_1 = 1, shape_2 = 1, | |
x_min = qbeta(0.0001, shape_1, shape_2), | |
x_max = qbeta(0.9999, shape_1, shape_2)){ | |
x <- seq(x_min, x_max, length.out = 1000) | |
y <- dbeta(x, shape_1, shape_2) | |
plot(x, y, | |
type = "l", | |
ylab = "density", | |
xlab = "probability", | |
main = paste0("Beta(", shape_1, ", ", shape_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
# Mapping NSW Current Incidents in R ------------------------------------------- | |
library(sf) | |
library(mapview) | |
library(tidyverse) | |
#' Current Incidents Feed (GeoJSON) | |
#' This feed contains a list of current incidents from the NSW RFS, | |
#' and includes location data and Major Fire Update summary information where available. | |
#' Click through from the feed to the NSW RFS website for full details of the update. |
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
# tidyr::complete() & tidyr::full_seq() ----------------------------------- | |
# Turning implicit missing values into explicit missing values. | |
# Bonus: Filling in gaps in a date range | |
library(tidyr) | |
library(tibble) | |
library(dplyr) | |
# Making up some observations from two weather stations. |
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
# source: https://twitter.com/internetdepths/status/1564949689962827776 | |
library(tibble) | |
tibble( | |
year = 1993:2003, | |
fatalities = c(237, 233, 209, 194, 150, 168, 187, 161, 168, 202, 255), | |
rate_per_thous_soldiers = c(0.35, 0.36, 0.34, 0.33, 0.26, 0.29, 0.33, 0.28, 0.28, 0.34, 0.38) | |
) |