Aerobic decoupling / cardiac drift calculator

If you are reading this page, you were probably looking for this one instead: https://douglas-watson.github.io/aet-calc/.

How To Export Apple Podcasts to mp3 Files

Apple Podcasts allows downloading of episodes for offline use. The problem is getting those files out of the app into non-Apple devices. I fixed that with an Automator workflow which you can also install.

Read On →

Fitting exponential decays in R, the easy way

Exponential decays can describe many physical phenomena: capacitor discharge, temperature of a billet during cooling, kinetics of first order chemical reactions, radioactive decay, and so on. They are very useful functions, but can be tricky to fit in R: you'll quickly run into a 'singular gradient' error. Thankfully, self-starting functions provide an easy and automatic fix. Read on to learn how to use them.

Read On →

Curve fitting on batches in the tidyverse: R, dplyr, and broom

Updated August 2020: changed to broom’s newer nest-map-unnest pattern, from the older group_by-do pattern. I recently needed to fit curves on several sets of similar data, measured from different sensors. I found how to achieve this with dplyr, without needing to define outside functions or use for-loops. This approach integrates perfectly with my usual dplyr and ggplot2 workflows, which means it adapts to new data or new experimental conditions with no changes. Read On →

An interactive map of mass shootings based on Shiny

“Four? That’s barely your average family murder-suicide!” - Anonymous American The United States saw 427 mass shootings in 2017, making a total of 2571 victims. That’s more than one shooting per day. Why don’t you hear about them on the news every day? Or conversely, if they are so common, why did the recent shooting in Las Vegas or the night club shooting in Orlando get so much attention? Read On →

How to add Google Analytics to a Shiny application

I recently wanted to add a Google Analytics tracker to a Shiny dashboard, and I found that the official documentation doesn’t explain how to include “Global Site Tag” tracking code, which seems to be the current default setting in Analytics. The process is simple, we just have to include the tracking code as an HTML snippet in ui.R. The process requires only two steps: Copy the analytics HTML snippet into a text file Reference the file in ui. Read On →

How to change the number of breaks on a datetime axis with R and ggplot2

It took me a surprising amount of time to find how to change the tick interval on ggplot2 datetime axes, without manually specifying the date of each position. The solution is surprisingly simple and clear once you know the syntax: scale_x_datetime(date_breaks = "12 hours") This places a break every 12 hours. The interval can be any value accepted by the scales package: “sec”, “min”, “hour”, “day”, “week”, “month”, or “year”. The trailing s is ignored. Read On →

Build an internet-of-things dashboard with Google Sheets and RStudio Shiny: Tutorial part 3/3

This is the third and final part of the Shiny + Google Docs dashboard tutorial, where I explain how to build a live web dashboard for connected “Internet of Things” sensors, using Google Sheets as a data server. Part one covered setting up a Google Sheet to store and serve data through HTTP requests; part two covered reading, filtering, and plotting that data in R. In this part, we’ll create the actual dashboard and host it online. Read On →

Build an internet-of-things dashboard with Google Sheets and RStudio Shiny: Tutorial part 2/3

This is the second installment of the Shiny + GDocs dashboard tutorial, where we learn how to use a Google Sheet spreadsheet to store data from connected “Internet of Things” data and use Shiny to create a web page to show the data. The first part showed you how to set up a Google Sheet to serve as a data server that accepts POST and GET HTTP requests, as well as how to use pivot tables and filters on the sheets directly. Read On →

Build an internet-of-things dashboard with Google Sheets and RStudio Shiny: Tutorial part 1/3

In part one of this tutorial, you will learn how to script a Google Sheet to store data from your hardware using an HTTP POST request and to retrieve the sheet’s data using an HTTP GET requests. Along the way, you will also experiment with some of the spreadsheet’s built-in analytics tools: filters, pivot tables, and charts. Skip to part 2 to learn how to fetch and manipulate this data in R, or part 3 to learn how to use Shiny. Read On →