Skip to content

Instantly share code, notes, and snippets.

docker pull ghcr.io/rocker-org/verse:4.3.3
docker run --rm -ti ghcr.io/rocker-org/verse:4.3.3  bash
 
quarto create project book abook

cd abook
## I turned off PDF rendering in _quarto.yml because lots of deps
quarto render
@rmcelreath
rmcelreath / p_under_null.r
Created July 7, 2023 14:24
distribution of pvalues under null for t.test and binomial models
# distribution of null p-values in binomial glm
library(rethinking)
# t test
# pval has uniform distribution under null
f <- function(N=10) {
y1 <- rnorm(N)
y2 <- rnorm(N)
@mcandre
mcandre / elecraft-kx3-cheatsheet.md
Last active December 8, 2023 05:05
Elecraft KX3 Cheatsheet

Elecraft KX3 Cheatsheet

The KX3 transceiver is designed for HF amateur band operation. The KX3 natively supports 160m - 6m.

An optional 2m accessory can extend the band support to 2m, though the installation of that accessory is a more intensive, electronics hobbyist task.

WARNINGS

As with all radios, do not transmit when the antenna is disconnected. Avoid touching the antenna or feed line when transmitting. Power down the radio and disconnect the feed line when making antenna adjustments.

@gaborcsardi
gaborcsardi / Pkgdown deploy from Travis.md
Last active November 17, 2021 13:41
Walkthrough: deploy a pkgdown site from Travis

Run usethis::use_pkgdown_travis()

usethis::use_pkgdown_travis()
✔ Setting active project to '/Users/gaborcsardi/works/ps'Adding 'docs/' to '.gitignore'Set up deploy keys by running `travis::use_travis_deploy()`Insert the following code in '.travis.yml'
  before_cache: Rscript -e 'remotes::install_cran("pkgdown")'
@vankesteren
vankesteren / wine_plots.R
Last active April 21, 2021 09:58
Plots for a wine data visualisation
# script that outputs a graph
library(tidyverse)
library(firatheme)
wine <- read_delim("https://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data",
delim = ",",
col_names = c(
"Cultivar", "Alcohol", "Malic acid", "Ash", "Alcalinity of ash", "Magnesium",
"Total phenols", "Flavanoids", "Nonflavanoid phenols", "Proanthocyanins",
"Color intensity", "Hue", "OD280/OD315", "Proline"
)
@pat-s
pat-s / addins.json
Last active March 2, 2020 09:58
Apply RStudio Desktop Settings
{
"styler::style_active_file": "Ctrl+Y",
"addmins::insert_dashes": "Ctrl+8",
"xaringan::inf_mr": "Ctrl+M",
"drake::rs_addin_loadd": "Ctrl+K",
"browse::browse": "Ctrl+B"
}
@clanfear
clanfear / gist:e160ba2ddf5e90c7bc70dbd2cfb0dd94
Created August 15, 2019 18:44
Using sf and tidyverse to get weighted mean of neighbors for all columns
library(tidyverse)
library(sf)
st_queen <- function(a, b = a){
st_relate(a, b, pattern = "F***T****")
}
new_data <- original_data %>%
mutate(neighbors = st_queen(.)) %>%
st_drop_geometry() %>%
st_recenter <- st_recentre <- function(x, clon = NULL, ..., tryfix = TRUE) {
if (is.null(clon)) return(x)
if (!st_is_longlat(x)) stop("recentring not appropriate for non longlat data")
## try to fix problematic geometry
if (tryfix) {
if (all(grepl("POLYGON", st_geometry_type(x)))) x <- suppressWarnings(st_buffer(sf::st_as_sf(x), 0))
x <- st_wrap_dateline(x, options = c("WRAPDATELINE=YES", "DATELINEOFFSET=180"))
}
wbox <- st_as_sfc(st_bbox(c(xmin = -180, ymin = -90, xmax = (clon)%%360 - 180, ymax = 90), crs = st_crs(x)))
west <- suppressWarnings(st_intersection(x, wbox))
@joeroe
joeroe / tidy_rcarbon.R
Created March 5, 2019 10:45
Tidy wrappers for the rcarbon package
# tidy_rcarbon.R
# Tidy wrappers for the rcarbon package
#' Calibrate radiocarbon dates with tidy syntax
#'
#' A thin wrapper of [rcarbon::calibrate()] that returns calibrated dates as a
#' single list rather than a `CalDates`` object. Useful, for example, if you want
#' to add a column of calibrated dates to an existing table with [dplyr::mutate()]
#'
#' @param cra A vector of uncalibrated radiocarbon ages.
@LiYingWang
LiYingWang / wikipedia-page-edit-proportions.R
Last active February 11, 2019 07:04 — forked from benmarwick/wikipedia-page-edit-proportions.R
Inspect the edit history of a bunch of wikipedia pages to measure the proportion of the page contributed by each editor
library(tidyverse)
the_pages <- c(
"https://en.wikipedia.org/wiki/Angela_McGowan",
"https://en.wikipedia.org/wiki/Caroline_Bird_(archaeologist)",
"https://en.wikipedia.org/wiki/Jo_McDonald",
"https://en.wikipedia.org/wiki/Laurajane_Smith",
"https://en.wikipedia.org/wiki/Louise_Zarmati",
"https://en.wikipedia.org/wiki/Marcia-Anne_Dobres",
"https://en.wikipedia.org/wiki/Sarah_Colley",