Data Analysis

Do I Love or Hate R’s knitr?

Depends. I’m sharing my love/hate experience with knitr. When it works, it’s divine. When it doesn’t, it’s diabolical. knitr is finally working well in my local PC’s RStudio, but I find that I’m running knitr every hour or so to make sure I have not introduced something into my .rmd file that breaks it. I had wrongly assumed that knitr basically takes a “screen capture” or the like of my .rmd file and outputs the page as html, PDF, etc. In fact, knitr executes EVERYTHING in my ever-growing project .rmd file and if, say, a variable is undefined or I have an R code chunk that has the same name, knitr will barf and halt execution resulting in nada, nil, zip, nothing, nichevo. That’s why I run knitr several times a day, and good thing that I do because it catches stuff. I don’t want to wait for my project to be complete only to find that I have to spend hours fixing syntax errors (whatever) that knitr so gleefully finds. Onward.

knitr-peter-bakke