2

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")
})
```
JasonAizkalns
  • 20,243
  • 8
  • 57
  • 116

1 Answers1

3

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.

JasonAizkalns
  • 20,243
  • 8
  • 57
  • 116
  • There was a nice overview webinar of `htmlwidgets` provided by RStudio that was helpful that hints at why you need a `render` method per each type of widget. – JasonAizkalns Apr 14 '15 at 19:04
  • any suggestions wich render function to use when I am plotting with ggvis? I actually watched the webinar, but I dont recall any special rendering function they were using... – maRtin Apr 14 '15 at 20:48