简体   繁体   中英

Shiny apps in rmarkdown websites and HTML dependencies

I've recently created an rmarkdown website. I now want to have a page that highlights basic Shiny functionality. This is possible using the runtime: shiny option for normal markdown documents. However, when I use this:

---
title: "Untitled"
runtime: shiny
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

```{r}
inputPanel(
           sliderInput("obs", "observations:", min = 10, max = 500, value = 100)
           )
           renderPlot({hist(rnorm(input$obs), col = 'darkgray', border = 'white')})
```

and try to build the site, I get the following error:

在此输入图像描述

I've made sure all of my packages are up to date.

I get the feeling I may be fundamentally misunderstanding how websites (and Shiny ) work, but I can't find an explicit answer to my question in the authoring Shiny document, embedded Shiny page or the rmarkdown website guide.

Is this a case of Shiny apps not being deployable on websites in this fashion at all? Or am I just being dense?

EDIT: output from sessionifo() :

> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Antergos Linux

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

loaded via a namespace (and not attached):
 [1] backports_1.0.5 magrittr_1.5    rprojroot_1.2   htmltools_0.3.5
 [5] tools_3.3.2     yaml_2.1.14     Rcpp_0.12.9     stringi_1.1.2  
 [9] rmarkdown_1.3   knitr_1.15.1    stringr_1.1.0   digest_0.6.12  
[13] evaluate_0.10  

When you use Shiny controls in r-markdown, you do not embed the application, you embed pieces of the application. For example if you wanted to do that shiny app in r-markdown you would use this code:

---
title: "Untitled"
runtime: shiny
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

```{r}
    inputPanel(
      sliderInput("obs", "observations:", min = 10, max = 500, value = 100)
    )
    renderPlot({hist(rnorm(input$obs), col = 'darkgray', border = 'white')})
```

Which yields this when compiled (and the controls work and the plot updates):

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM