The Cost of True Love (a.k.a. The Tidy — and expensive! — Twelve Days of Christmas)

pnc_price_index-1

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:

  • Grab the lyrics
  • Parse the lyrics
  • Get pricing data
  • Compute some statistics
  • Make some (hopefully) pretty charts

This one was complex enough formatting-wise that I needed to iframe it below. Feel free to bust out of the iframe at any time.

Some good follow-ups to this (if you’re so inclined) would be to predict prices next year and/or clean up the charts a bit.

Grab the code up on GitHub.

(Note: ColourLovers API times out occasionally so just try that snippet again if you get an error).

Cover image from Data-Driven Security
Amazon Author Page

5 Comments The Cost of True Love (a.k.a. The Tidy — and expensive! — Twelve Days of Christmas)

  1. Pingback: The Cost of True Love (a.k.a. The Tidy — and expensive! — Twelve Days of Christmas) – Cloud Data Architect

  2. Pingback: The Cost of True Love (a.k.a. The Tidy — and expensive! — Twelve Days of Christmas) - biva

  3. Pingback: The Cost of True Love (a.k.a. The Tidy — and expensive! — Twelve Days of Christmas) – Mubashir Qasim

  4. Lod

    I am unable to run the code.The line below results in an error

    decapitated::chrome_shot(

    “http://www.genekeyes.com/12-DAYS/12-days-of-Christmas.html#Lyrics”,

    path=file.path(rt, “lyrics.png”)

    )

    it triggers an error in processx:

    Error in process_initialize(self, private, command, args, commandline, :
    processx error

    Could it be due to args?

    processx::run(command = chromebin, args = args, erroronstatus = FALSE,
    echo
    cmd = FALSE, echo = FALSE)

    chrome_bin resolves to the correct path
    Error: args is not a character vector

    Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.