The Mission

I’m in the market for Christmas presents for my true love, @mrshrbrmstr, and thought I’d look to an age-old shopping list for inspiration Just what would it set me back if I decided to mimic the 12 Days of Christmas in this modern day and age?

Let’s try to do the whole thing in R (of course!).

We’ll need to:

We’ll need some R packages to help us along the way:

library(rprojroot) # where am I?
library(stringi) # better string ops
library(rvest) # web data
library(httr) # web data
library(V8) # work with javascript
library(hrbrthemes) # pretty things
library(colourlovers) # i wanted a christmas palette
library(magick) # magic
library(decapitated) # devtools::install_github("hrbrmstr/decapitated")
library(fuzzyjoin) # data manip
library(tidyverse) # tidyvers

I’m also using knitr, kableExtras and DT but provide full (::) function reverences vs pollute the namespace (we’ve got quite a bit in the namespace as it stands).

rt <- find_rstudio_root_file()

The stuff

Despite the fact that lyric sites steal content from other sites, they still put up barriers to scrape said grifted content. So, we have to pick a site without scraping restrictions, which can mean we get data but may have to massage it a bit.

I found this site and it has what we need, but the content will need work.

path=file.path(rt, "lyrics.png")