Publications by Higher Order Functions
Snecko eye lets you play more cards
In a previous post, I used simulations to estimate how long it would take to collect the unique Unowns in Pokemon Go! The message of the post was that we can use simulations to solve problems when the analytic solution is not clear or obvious. The current post is an another example of using simulations to understand a weird counting/probability p...
7755 sym R (6307 sym/10 pcs) 10 img 1 tbl
Keep your R scripts locally sourced
A few weeks ago, I had a bad debugging session. The code was just not doing what I expected, and I went down a lot of deadends trying to fix or simplify things. I could not get the problem to happen in a reproducible example (reprex) or interactively (in RStudio). Eventually, the most minimal example of the problem completely broke my mental mode...
5893 sym R (5124 sym/6 pcs) 2 img
A one-liner for generating random participant IDs
On one of the Slacks I browse, someone asked how to de-identify a column of participant IDs. The original dataset was a wait list, so the ordering of IDs itself was a sensitive feature of the data and we need to scramble the order of IDs produced. For example, suppose we have the following repeated measures dataset. library(tidyverse) data <- tib...
2321 sym R (10169 sym/13 pcs)
Custom syntax highlighting themes in RMarkdown (and pandoc)
I recently developed and released an R package called solarizeddocx. It provides solarizeddocx::document(), an RMarkdown output format for solarized-highlighted Microsoft Word documents . The image below shows a comparison of the solarizeddocx and the default docx format: Side-by-side comparison of solarizeddocx::document() and rmarkdown::...
6743 sym R (10243 sym/21 pcs) 18 img
Self-documenting plots in ggplot2
When I am showing off a plotting technique in ggplot2, I sometimes like to include the R code that produced the plot as part of the plot. Here is an example I made to demonstrate the debug parameter in element_text(): library(ggplot2) self_document( ggplot(mtcars, aes(x = mpg)) + geom_histogram(bins = 20, color = "white") + labs(title ...
3700 sym R (7988 sym/15 pcs) 22 img