Notes
Notes-to-self and other noodlings.
2026
ggplot2 loops and delayed evaluation in aes() This note solves a problem faced by Josiah Parry (relevant gist and Bluesky post) Generating...
Using downlit on knitr code chunks for Jekyll I wanted to use downlit to add package/function links to code blocks in my Jekyll...
ggplot2 geom default aesthetics (pre-4.0 behavior) ggplot2 4.0.0 changed how geoms get their default aesthetics: many defaults are now looked up...
Zapping orphaned/outdated rendered notes I write notes in RMarkdown and then use knitr to convert them to Jekyll-friendly markdown....
2025
A leave-one-out apply helper I had to compare how each listener differed from the mean of the other listeners,...
Bits and pieces This entry collects some quick quotes and links.
Computing the mean of the logit-normal with Stan's integrate_1d() Here is a quick note on using Stan to compute a 1-dimension integral.
Positron notes Getting up and running with R is pretty straightforward: install R, install RStudio, install packages...
Three meanings of weights in statistics There are three different meanings of “weights” in statistics explains Thomas Lumley: Precision/analytic weights, frequency...
Resuming a renv project without restoring the environment Steps for resuming a renv project when you don’t care about restoring the previous package...
Selecting models from lists and running anova() I was making a notebook with a list of related models, like
Model condition number and kappa() A colleague got the following warning when fitting a regression model in Python:
Confidence interval overlap and p-values Two 95% confidence intervals can overlap and still have a statistically significant difference at p...
Don’t compare discrete and continuous models with AIC Don’t use AIC to compare a discrete and a continuous model says Thomas Lumley. “The...
Serializing rvars with qs2's qdata I was surprised by how large a tibble with posterior::rvar() columns became when saved with...
sweep() demo sweep(data, margin, stats, fun) is a goofy function for adjusting cols or rows. For example,...
'A random variable is not random and not a variable' “A random variable is not random and not a variable”. Yep, it’s a random number...
Log-likelihood functions These two ways of computing the log-likelihood (an automatic way and naive way) differ because...
Use GAMs for assessing nonlinearity of effects A Data Colada post describes a problem and one proposed solution: how to assess a...
Bits and pieces This entry collects some quick links and tips.
2024
local_ and with_ symmetry in withr I was reading the withr 3.0.0 release notes and noticed a pleasing symmetry the with_...
Helper functions for vector indexing and manipulation Here are some pipe-friendly functions I made during an Advent of Code run. When I...
targets + crew for parallel builds In targets, by default, targets are dispatched to be built one at a time, but...
Making targets handle large bootstrap workflows Here is a summary of how I got targets to handle a bunch of bootstrapping:...
Sentence similarity with dot product and cosine similarity I read an article I had bookmarked for a while. Suppose you have word embedding...
How to write an 'iterative' recursive function I revisited SICP during the Christmas break. I don’t know why this stuck out to...
The pipe placeholder works better now Andrew Heiss pointed out to me that the placeholder since 4.3.0 is a lot better....
purrr::pluck() accepts accessor functions purrr::pluck() is better than I had realized. ?purrr::pluck():
Simulation for a probability paradox This paradox is a flavor of the Sleeping Beauty paradox or the Boy or Girl...
A null-safe map() function I got sick of writing null-guard clauses like:
Mutual recursion and Tailcall() in R I toyed with the experimental Tailcall() feature in R-devel. I can’t actually run this code...
MFA installation: do not change the conda solver My colleague and I independently ran into an issue where the Montreal Forced Aligner installation...
A custom knitr engine for blockquotes Here’s how easy it is to create a knitr language engine:
2023
Gompertz functions and parameterization The Gompertz function “describes growth as being slowest at the start and end of a...
2022
Using DuckDB with dplyr to query control files duckdb is awesome. I used it in a project to read in all of control...
Windows Terminal settings for Miniconda Here is how to add the Miniconda prompt to Windows Terminal. Analogous steps probably will...
The BIC I was wondering about the so-called Bayesian information criterion (BIC) today. What’s the deal with...
Getting downlit to work on notebook HTML notestar, which I use to create project notebooks, produces an HTML file. I can then...
renv transactional installs and my .Rprofile setup I am now adding the following to my .Rprofile file. By default, renv::restore() will undo...
R 4.2.0 alpha notes on Windows These are some notes about workarounds etc. for the devel/alpha version of R 4.2.0 that...
Visualizing ordinal model probabilities with ribbons Here is a ggplot2 recipe for plotting cumulative probabilities from ordinal regression models.
Random walk with a ceiling constraint I had some old code that asked what a 12-step random walk looked like if...
Phonotactic probability and parsing KU calculator output in R I asked the PhonCorps Slack what the state of the art was for computing phonotactic...
Sampling from a multinomial with sample() drob dropped this tweet:
Deleting or blanking a facet cell in ggplot2 Suppose you have some ragged data.
Manually computing spline predictions from a GAMLSS model My goal is write down some reusable code for how to get spline predictions for...
Conditionally returning tibbles with delayedAssign() The newsletter by rOpenSci highlights this trick by the palmerpenguins package.
Counting function calls using getParseData() We can do data analysis on getParseData() result.
2021
Leslie matrices for population growth Advent of Code day 6 (simulating population growth) can be done with matrix multiplication on...
Sampling bias: the swimming pool analogy Jorbs on his Slay the Spire stream commented problems with big data. He used a...
Base graphics in knitr and global.par I learned while porting over some old notes that par() options are not preserved between...
A Gaussian KDE is a sum of little Gaussians Today I learned from here that the Gaussian KDE is the sum of a bunch...
Using closures to make 16 related functions The R Open Sci newsletter linked to a mailing list thread about how to stash...
eval() vs rlang::eval_bare() semantics eval() is stack inconsistent (whatever that means)
2019
Controlling geom_lineribbon() legend order and aesthetics [This note dates back to 2019 but I’ve updated it to run with ggplot2 4.0.0...
Added variable plots (partial regression plots) Here’s what “added variable” plots are about.
Standardizing gamma distributions via scaling A gamma times a positive non-zero constant is still a gamma. Paul and I used...
Jaccard similarity for transcription reliability Jaccard similarity is the size of intersection of A and B divided by size of...
Bits and pieces The entry collects short notes, quotes, and links.