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")
})
```
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.