Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Shiny Presentation from Shiny App?

I found this - http://shiny.rstudio.com/gallery/download-knitr-reports.html - awesome example that can create static PDFs, HTMLs, and Word Docs.

What I want to be able to do is upload a data set that can then generate a templatized Shiny Presentation. I've tried multiple routes with little success. The furthest I've gotten is including this code in my markdown file:

---
title: "shinyPresentation"
author: "maloneypatr"
date: "Wednesday, September 03, 2014"
output:
  ioslides_presentation:
    self_contained: false
    lib_dir: libs
runtime: shiny
---

Upon trying to download the sample .HTML file, I get this error path for html_dependency not provided. Am I chasing a functionality that doesn't currently exist? If not, does anyone have some advice?

Thanks in advance!

--UPDATE AFTER YIHUI'S COMMENT--

>library(rmarkdown);library(shiny);sessionInfo()

R version 3.1.1 (2014-07-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rmarkdown_0.2.47    knitr_1.6           shiny_0.10.1        ggmap_2.3           googleVis_0.5.5    
[6] stringr_0.6.2       gdata_2.13.3        fileR_1.0           plyr_1.8.1          XLConnect_0.2-9    
[11] XLConnectJars_0.2-9 dplyr_0.2           bigrquery_0.1       devtools_1.5        statebins_1.0      
[16] RColorBrewer_1.0-5  gridExtra_0.9.1     scales_0.2.4        ggplot2_1.0.0       httr_0.4           

loaded via a namespace (and not attached):
[1] assertthat_0.1.0.99 bitops_1.0-6        Cairo_1.5-5         caTools_1.17        colorspace_1.2-4   
[6] digest_0.6.4        evaluate_0.5.5      formatR_0.10        gtable_0.1.2        gtools_3.4.1       
[11] htmltools_0.2.4     httpuv_1.3.0        jsonlite_0.9.8      labeling_0.2        magrittr_1.0.1     
[16] mapproj_1.2-2       maps_2.3-7          markdown_0.7        MASS_7.3-33         memoise_0.2.1      
[21] mime_0.1.1          munsell_0.4.2       parallel_3.1.1      png_0.1-7           proto_0.3-10       
[26] psych_1.4.8.11      Rcpp_0.11.2         RCurl_1.95-4.1      reshape2_1.4        RgoogleMaps_1.2.0.6
[31] rJava_0.9-6         rjson_0.2.14        RJSONIO_1.2-0.2     tools_3.1.1         whisker_0.3-2      
[36] xtable_1.7-3        yaml_2.1.13   

This is my updated report.Rmd file:


title: "shinyPresentation"
author: "maloneypatr"
date: "Wednesday, September 03, 2014"
output:
  ioslides_presentation:
    self_contained: false
    lib_dir: libs
runtime: shiny
---

## Shiny Presentation

This R Markdown presentation is made interactive using Shiny. The viewers of the presentation can change the assumptions underlying what's presented and see the results immediately. 

To learn more, see [Interative Documents](http://rmarkdown.rstudio.com/authoring_shiny.html).

## Slide with Interactive Plot

```{r, echo=FALSE}
inputPanel(
  selectInput("n_breaks", label = "Number of bins:",
              choices = c(10, 20, 35, 50), selected = 20),

  sliderInput("bw_adjust", label = "Bandwidth adjustment:",
              min = 0.2, max = 2, value = 1, step = 0.2)
)

renderPlot({
  hist(faithful$eruptions, probability = TRUE, breaks = as.numeric(input$n_breaks),
       xlab = "Duration (minutes)", main = "Geyser eruption duration")

  dens <- density(faithful$eruptions, adjust = input$bw_adjust)
  lines(dens, col = "blue")
})
```
like image 849
maloneypatr Avatar asked Mar 18 '23 13:03

maloneypatr


1 Answers

Am I chasing a functionality that doesn't currently exist?

A little bit. :-)

Interactive Shiny presentations (and documents) can't be saved as HTML. They need a server to run the R code they contain. What's happening is that your app is trying to render an interactive presentation to a static HTML file, which isn't supported.

The short answer then is that instead of "Download" you need a "Run", which calls rmarkdown::run instead of rmarkdown::render.

If you're looking for a downloadable asset, the best you can do is probably to have a download of the .Rmd itself, with appropriate string replacements for the current UI state; this .Rmd can then be run at any time with rmarkdown::run.

like image 56
Jonathan Avatar answered Apr 02 '23 18:04

Jonathan