Shiny renderPlot within Interactive Document opens a new Browser Window with dygraph

巧了我就是萌 提交于 2020-01-04 09:29:10

问题


I have the following RMarkdown .Rmd document. When you run the following, the sliderInput is "reactive" and adjust the smoothing appropriately; however, the plot keeps generating in a new separate browser window rather than within the document itself.

Any ideas why this is happening or how to fix this behavior?

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

```{r echo=FALSE}
library(dygraphs)
sliderInput("span", label = "Select Span",
            min=0.05, max=1, value=0.5, step=0.05)

renderPlot({
  plx <- predict(loess(ldeaths ~ time(ldeaths), span=input$span), se =T)
  fit <- plx$fit
  lower <- plx$fit - qt(0.975, plx$df) * plx$se
  upper <- plx$fit + qt(0.975, plx$df) * plx$se
  all <- cbind(ldeaths, fit, lower, upper)

  dygraph(all, main="Title") %>%
    dySeries(c("lower", "fit", "upper"), label="Deaths")
})
```

回答1:


Well, I'm an idiot, the answer is that there's already a renderDygraph() function within the dygraphs package!

I'm going to keep this open so maybe someone can explain to me what's going on behind the scenes that makes this work correctly and why you cannot use renderPlot() directly. I will try and remember to update this answer if I learn from looking through the source.



来源:https://stackoverflow.com/questions/28467455/shiny-renderplot-within-interactive-document-opens-a-new-browser-window-with-dyg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!