Skip to content

Instantly share code, notes, and snippets.

View mevers's full-sized avatar

Maurits Evers mevers

  • Canberra, Australia
View GitHub Profile
@mevers
mevers / rain_in_Canberra.R
Last active January 16, 2024 05:53
Rainfall Canberra last decade
library(tidyverse)
library(hrbrthemes)
library(ggrepel)
library(weatherBOM)
# Return day of the season
sday <- function(date, season = "summer") {
switch(
season,
summer = if_else(month(date) %in% c(12, 1, 2), yday(date %m+% months(1)), NA),
---
title: "Untitled"
output: html_document
date: "2022-10-22"
---
```{r, echo = FALSE}
htmltools::tagList(
htmltools::tags$script(src = "https://code.highcharts.com/highcharts.js"),
htmltools::tags$script(src = "https://code.highcharts.com/highcharts-more.js"),
@mevers
mevers / gist:5cbdd5305d5ecc7b09cabd4cda1c227c
Created January 17, 2022 21:30
Sample data for max demand model
# Source: Rosetta RIN Data Portal
# Years: 2007-2021 (FYEs)
# Extraction/update timestamp: 10/01/2022
year,field,description,unit,value
2010,DOPED01,Total energy delivered,GWh,2873
2011,DOPED01,Total energy delivered,GWh,2896
2012,DOPED01,Total energy delivered,GWh,2910
2013,DOPED01,Total energy delivered,GWh,2891
2014,DOPED01,Total energy delivered,GWh,2904
2015,DOPED01,Total energy delivered,GWh,2856.060
## Gist for https://discourse.mc-stan.org/t/dose-response-model-with-partial-pooling/13823
##
## Version 28 March 2020
##
## Changelog:
## - Priors on `c` and`d` are now lognormals (see @arya's comments)
## - Fixed priors on the hyperparameters for `d` (see @FJCC's comments)
#
# _Originally_
## mu_d ~ normal(max(y), 5);
---
title: "Untitled"
output: ioslides_presentation
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## Sample plotly
@mevers
mevers / my.vennDiagram.R
Last active August 27, 2020 08:42
Modified limma::vennDiagram to remove box and add label
my.vennDiagram <- function (object, include = "both", names = NULL, mar = rep(1,
4), cex = c(1.5, 1, 0.7), lwd = 1, circle.col = NULL, counts.col = NULL,
show.include = NULL, ...)
{
include <- as.character(include)
LenInc <- min(length(include), 2)
if (is(object, "VennCounts")) {
include <- include[1]
LenInc <- 1
}
@mevers
mevers / gist:2896db9a87c52e6c6fe1cf8fe0ccac78
Created February 20, 2018 11:40
Cox PH with censored data
# Data from Stata manual, p.5:
# "We wish to analyze an experiment testing the ability of emergency
# generators with a new-style bearing to withstand overloads. For this
# experiment, the overload protection circuit was disabled, and
#the generators were run overloaded until they burned up. "
# https://www.stata.com/manuals13/ststcox.pdf
df <- read.table(text =
"failtime load bearings
100 15 0
140 15 1
@mevers
mevers / sample_text.txt
Created August 9, 2017 22:31
RMarkdown workshop sample text
PROLOGUE
A long time ago, in a galaxy far, far away...
The Clone Wars were over, leaving entire civilizations in ruin. The Jedi Knights were all but extinct. And the Old Republic — the democratic galactic government that had prevailed for almost 25,000 years — had been replaced by the Galactic Empire.
Yet the Empire’s supreme ruler, the evil Emperor Palpatine, remained hungry for even more power. To expand his rule and crush all remnants of the Old Republic, Palpatine had approved the construction of a secret weapon: the Death Star, an immense armored space station that could destroy an entire planet.
The Empire was not without opposition. The Alliance to Restore the Republic — commonly known as the Rebel Alliance — led the fight to overturn the Empire and bring justice and freedom back to the galaxy.
@mevers
mevers / install_workshop_libs.R
Last active August 14, 2017 01:46
Install packages for RMarkdown workshop
# Install packages for RMarkdown workshop
pkg <- c("ggplot2", "rmarkdown", "knitr", "dplyr", "hrbrthemes", "scatterD3", "pander", "xtable", "DT", "plotly");
lapply(pkg, function(x) { if (!require(x, character.only = TRUE, quietly = TRUE)) {
cat(sprintf("Installing R package %s\n", x));
install.packages(x, repos = "http://cran.rstudio.com/");
require(x, character.only = TRUE, quietly = TRUE)}
})