Search code examples
rrstudioknitrlyx

R package knitr misses R chunks


I haven't been able to use the neater knitter package with the code chunks.

Basically there's only a few number of occasions in which it interprets them well, but for the most of it the chunks are not recognized as such. That is:

  • Running a markdown from RStudio only renders chunks before the file is saved. If the file has been saved, then it will show the code as is: no R output.
  • I also tried using knitr from within LyX, and this presented other problems. The simplest example knitr.lyx was rendered correctly as a pdf, but not html. Using more complicated documents, like the RJournal template showed other errors.
    Rscript --verbose --no-save --no-restore

At first I thought it had to do with my Rstudio installation, but now I'm not so sure anymore.

By the way, I'm on Ubuntu 15.04 and the files that I'm using are examples from the documentation:


Solution

  • I found the answer for this.
    It's very obvious and yet easy to overlook if you don't know it.
    The problem was in saving the file with the wrong extension. If you're using R code chunks you need .Rmd extension in Rstudio.

    As I was starting with markdown I was using .md. Pfff.