Background Lesson 1: check suggested packages Lesson 2: MODULARIZE + use vagrant scripts with caution Internet solutions Conclusion Today marks the second time I’ve debugged the problem of tests that pass with devtools::test() but fail with devtools::check(). Since I’m now riding my debug-success high (and hope never to repeat this again), here is a blogpost.
Background There are some resources online (see below) to help with debugging this particular problem, but they are sparse and situation-specific.
httr basics On with the tricks! Embrace the backtick The null-default operator %||% Check argument inputs with match.arg() switch() out your if-elses Strange bedfellows tl;dr - do read the source code! Over the past few months, I worked on several projects that involved accessing web API’s in R, which meant I spent a lot of time puzzling over the functions and code in the httr package.
This week, I came across two news articles about a study in Nature led by Nick Graham that linked invasive rats on islands to coral reefs. I was intrigued by how the different authors (in this case, Ed Yong from the Atlantic and Victoria Gill from the BBC) reported on the study, and took it as a sign that I have should some fun with text analysis.
Rats on islands eat all the seabirds --> less guano --> less nitrogen flowing into the sea --> fewer fish in offshore coral reefs.