Monday, December 17, 2012

From d3 to pdf (hopefully knitr) with R Shiny

Although I think I like the d3, R, and Shiny team the best, I could definitely envision a big need for multi-page pdf reports created with R, knitr, and latex delivered to the browser with Shiny.  Shiny helpfully provides pre-built functionality to send .png charts and graphics created by R to the web.  This works especially well since most browsers offer containers for the graphics that can dynamically change.

In this quick experiment, I use the pdf() dev function from R instead of the hoped for knit2pdf to see if sending the binary pdf data is possible.  It seems the downloadHandler function from Shiny only currently handles text.  The downloadHandler function from Shiny also serves up downloads well.  I have included the code to get that to work also if you prefer this behavior.

Try it out at http://glimmer.rstudio.com/timelyportfolio/shiny-d3-pdf.  It seems to work with the newest Chrome and IE.

image

Code at Github.

No comments:

Post a Comment