使用Shiny Widets重新加载Rmd Html文档

时间:2015-12-12 23:40:08

标签: r shiny r-markdown

我正在寻找在R-markdown文件中使用Shiny小部件。我找到了这个例子,在markdown中运行它,然后将其保存为Html。但是当我加载它时,它会将窗口小部件呈现两次,然后挂起。

有没有办法可以避免这种情况,或者它是系统中的错误/已知限制?

以下是代码:

---
runtime: shiny
output: html_document
---

### Here are two Shiny widgets

```{r echo = FALSE}
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)
```

### ...that build a histogram.

```{r echo = FALSE}
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")
})
```

编译时它工作正常,但是当我保存它然后重新加载到Chrome,IE,Edge等...我得到了这个:

enter image description here

0 个答案:

没有答案