Publications by Higher Order Functions
Notes on Citing R and R Packages
Our group has started using a new knowledge base system, so I have been writing up and revisiting some of my documentation. Here I am going to share a guide I wrote about citing R packages in academic writing. Which software to cite Let’s make a distinction here between reporting (or summarizing) an analysis and reproducing (or carrying out) an a...
6368 sym R (8460 sym/8 pcs)
Ordering constraints in brms using contrast coding
Mattan S. Ben-Shachar wrote an excellent tutorial about how to impose ordering constraints in Bayesian regression models. In that post, the data comes from archaeology (Buck, 2017). We have samples from Layers in a site, and for each sample, we have a C14 radiocarbon date measurement and its associated measurement error. library(tidyverse) table1 ...
10225 sym R (15702 sym/18 pcs) 6 img
Creating a Summoning Salt-style speedrun plot
A videogame speedrun is a challenge to beat the game as quickly as possible. It’s time attack racing but for a videogame. There are, in my mind, two ways to make a run’s time go faster: Playing better and more smoothly (optimizations, having better luck) and playing less of the game (better routing, new glitches/skips). The history of a speed...
5565 sym R (13671 sym/12 pcs) 18 img
Confusion matrix statistics on late talker diagnoses
How many late talkers are just late bloomers? More precisely, how many children identified as late talkers at 18 months catch up to the normal range by one year later? This is an important question. From a clinical perspective, we want to support children with language delays, but it is also inefficient to spend resources fixing a self-correcting...
2976 sym R (2531 sym/3 pcs)
Why is using list() critical for .dots = setNames() uses in dplyr?
I wrote an answer about why setNames() shows up sometimes in standard evaluation with dplyr. My explanation turned into a mini-tutorial on why those standard evaluation functions have a .dots argument. The basic idea is that the usual variadic argument ... is a series of expressions that get evaluated inside of the dataframe. library("dplyr") #...
962 sym R (2433 sym/2 pcs)
Fixing APA citations from Pandoc with stringr
Pandoc is awesome. It’s the universal translator for plain-text documents. I especially like that it can do inline citations. I write @Jones2005 proved aliens exist and pandoc produces “Jones (2005) proved aliens exist”. But it doesn’t quite do APA style citations correctly. A citation like @SimpsonFlanders2006 found... renders as “Simp...
4472 sym R (1233 sym/6 pcs)
Recent adventures with lazyeval
The lazyeval package is a tool-set for performing nonstandard evaluation in R. Nonstandard evaluation refers to any situation where something special happens with how user input or code is evaluated. For example, the library function doesn’t evaluate variables. In the example below, I try to trick library into loading a fake package called e...
5378 sym R (5218 sym/15 pcs) 8 img
RStanARM basics: visualizing uncertainty in linear regression
As part of my tutorial talk on RStanARM, I presented some examples of how to visualize the uncertainty in Bayesian linear regression models. This post is an expanded demonstration of the approaches I presented in that tutorial. Data: Does brain mass predict how much mammals sleep in a day? Let’s use the mammal sleep dataset from ggplot2. This d...
10651 sym R (10763 sym/19 pcs) 16 img
Repeatedly applying a function
A colleague of mine sent me the following R question: I have a function that takes a list and does some stuff to it and then returns it. I then take that output and run it through the same function again. But I obviously don’t want to repeatedly type the function out, because I want the number of function replications to be a declared argument...
4334 sym R (2903 sym/10 pcs) 2 img
Simulating Unown encounter rates in Pokémon Go
Pokémon Go is an augmented reality game where people with smartphones walk around and catch Pokémon. As in the classic games, players are Pokémon “trainers” who have to travel around and collect creatures. Some types are rarer than others, some have regional habitats or biomes, and so players explore the game world to find and collect th...
8579 sym R (5846 sym/16 pcs) 8 img