Notebooks, knitr and the Language-Markdown View Source Option…

One of the foundational principles of the web, though I suspect ever fewer people know it, is that you can “View Source” on a web page to see what bits of HTML, Javascript and CSS are used to create it.

In the WordPress editor I’m currently writing in, I’m using a Text view that lets me write vanilla HTML; but there is also a WYSIWYG (what you see is what you get) view that shows how the interpreted HTML text will look when it is rendered in the browser as a web page.

viewtext

Reflecting on IPython Markdown Opportunities in IPython Notebooks and Rstudio, it struck me that the Rmd (Rmarkdown) view used in RStudio, the HTML preview of “executed” Rmd documents generated from Rmd by knitr and the interactive Jupyter (IPython, as was) notebook view can be seen as standing in this sort of relation to each other:

rmd-wysiwyg

From that, it’s not too hard to imagine RStudio offering the following sort of RStudio/IPython notebook hybrid interface – with an Rmd “text” view, and with a notebook “visual” view (eg via an R notebook kernel):

viewrmd

And from both, we can generate the static HTML preview view.

In terms of underlying machinery, I guess we could have something like this:

rmdviewarch

I’m looking forward to it:-)

9 comments

  1. r

    Are you familiar with the “editR” package? i haven’t used it much but when i have it seemed like a pretty useful live HTML previewer for Rmd docs. Not exactly the same as what you outline here, but similar…

    • Tony Hirst

      Ooh – no, that looks interesting… So you author in Rmd and it does a live view of the executed output in the View pane?

      I need to take a tim-out. Can;’t quite get my head round what each of these different models affords… But certainly seems that there’s now a variety of ways of doing literate programming where you get a live view of code output?

      • r

        I believe it pops up a new browser window entirely, then as you edit the file it live-updates. Again, I don’t have much experience with it; it just rang a bell when compared to what you were describing.

    • Tony Hirst

      @jan Thanks for all these… I guess a need to do a review of all the various approaches for myself to get a proper feel for the how they compare – and differ – in what they offer. (Unless you happen to know of such an review available elsewhere, of course?!)

  2. Ethan Brown

    Another potentially useful nugget for the mix: R Markdown to IPython Notebook

    I’m not totally clear on the the distinctions between notedown, which this solution depends on, and the seemingly similar ipymd. ipymd looks like a larger project which also has the goal of making a round-trip journey from md to ipymd.

    • Tony Hirst

      @ethan ah – thanks for that. I need to lay all this stuff out on the floor and then try to pull it back together in some sort of comparative framework to try to make sense of it and perhaps see where the gaps are, or missing conversion paths, if anyway. Not sure what such a thing would look like though!

  3. Pingback: » Interactive R Notebooks with Jupyter and SageMathCloud Statisfactions: The Sounds of Data and Whimsy
  4. Tony Hirst

    To try out Jupyter notebooks with a native R-kernel, the easiest way is probably to use a prebuilt docker container. Possible dockerfiles below:

    The easiest way of running docker containers is probably kitematic. At the time of writing, the Windows version of kitematic is in (request only?) alpha, but their pace of development seems to be such that it should be publicly available sometime soon…