Skip to content

Instantly share code, notes, and snippets.

View adamhsparks's full-sized avatar
🇦🇺

Adam H. Sparks adamhsparks

🇦🇺
View GitHub Profile
@adamhsparks
adamhsparks / mean_weather.R
Last active March 17, 2021 12:07
Download and calculate country and year mean values for weather variables using GSODR and dplyr
library("GSODR")
library("tidyr")
library("dplyr")
library("countrycode")
w <- get_GSOD(years = 1929:1931)
w <-
w %>%
group_by(CTRY, YEAR) %>%
@navicore
navicore / nvim-r.txt
Last active March 4, 2025 05:55
R cheatsheet and nvim-r commands
Menu entry Default shortcut~
Start/Close
. Start R (default) \rf
. Start R (custom) \rc
--------------------------------------------------------
. Close R (no save) \rq
. Stop (interrupt) R :RStop
-----------------------------------------------------------
@burchill
burchill / set_scales_constant.R
Last active June 17, 2024 01:51
Set continuous scales to be identical across ggplot2 plots automatically
# Check https://www.zachburchill.ml/constant_scales/ for a walkthrough.
# Note that this code is slightly "better" than the code in the post, since it checks
# to see if the scales being supplied and used are all continuous.
# Examples included after the function definitions.
# Given a bunch of plots and a scale you want to apply to them, this returns that scale,
# but with limits that encompass the union of all the ranges of values in those plots
# Meant to be for users
get_shared_scale <- function(..., scale) {
@ChandlerLutz
ChandlerLutz / dashes-plots.R
Last active January 30, 2024 14:53
Dashes, hpyhens, en dashes, and em dashes in R
# For Plots in R, need to use unicode dashes
# https://jkorpela.fi/dashes.html
# https://stackoverflow.com/a/27492072/1317443
# soft hyphen: `\u00ad` (Note that on macOS using the `Cairo` package that you don't need this; just type "-" on your keyboard)
# en dash: `\u2013`
# em dash: `\u2014`
##e.g.
@marvinjqs
marvinjqs / calculate_hourly_temp.R
Created June 29, 2020 01:16
Function to calculate hourly temperature and relative humidity from daily data of maximum temperature, minimum temperature, dew point and the coordinates of the station.
calcultate_hhr <- function(df_in_hhr) {
# Tn temp min, Tx temp max, To sunset , Tp temp min next
# Hn sunrise, Hx h temp max, Ho h sunset , Hp h temp min next
# date <- df_in_hhr[[1]]
#####
Tn <- as.numeric(df_in_hhr[[2]])
Tp <- as.numeric(df_in_hhr[[3]])
@tatianamac
tatianamac / tatiana-mac-speaker-rider.md
Last active April 22, 2025 22:44
Tatiana Mac's Speaker Rider

Speaker Rider

by Tatiana Mac

Last updated 14 April 2021

What is a speaker rider?

As speaking comes with immense privilege, I have crafted a speaker rider to set expectations and boundaries around my engagement. I am grateful to all the conference organisers who have brilliantly hosted me. I would love to continue to exercise this privilege to speak at conferences, and use this privilege to make the landscape more accessible and beneficial to tech's most historically excluded and marginalised communities.

Considerations

😫 I provide a lot of explanations for those of you who never had to consider these things. Most thoughtful conferences I've attended check most of these boxes intrinsically, particularly when conference runners are experienced speakers. They get it.

@adamhsparks
adamhsparks / bomrang_climogram.R
Last active July 3, 2019 04:32
Generate a climogram using bomrang to download station data for 2018/19 summer growing season in Australia
library(bomrang)
library(tidyverse)
library(theme.usq)
# Find stations ----------------------------------------------------------------
# Find nearest stations for each area
# search https://www.latlong.net/ for the lat lon values of each location
# clermont
@micahwoods
micahwoods / nasa_power_wisley.R
Created June 5, 2019 04:17
Gets global solar irradiance data from the NASA POWER agroclimatology data set, then plots it. This gist compares daily light integral near London, England, in the first 149 days of 2018 to the first 149 days of 2019.
# to look at The Wisley location data 2018 and 2019 based on
# this Q from Tom Coulson https://twitter.com/TomCoulson85/status/1135905779242995712
library(nasapower)
library(ggplot2)
library(cowplot)
library(RColorBrewer)
library(zoo)
# get the 2018 data
@MilesMcBain
MilesMcBain / darwin_vs_fisher.R
Created March 12, 2019 00:00
Compact solutions to the permutation test tweet thingie
``` r
library(purrr)
library(tibble)
darwin_data <-
tibble::tribble(
~pair, ~cross_fertilized, ~self_fertilized, ~difference,
1, 92, 43, 49,
2, 0, 67, -67,
3, 72, 64, 8,