rshinyr-markdown

Why slider input control dissapears when running rmd with render()


Just wondering if someone can help me with this. I have this small shiny app for Illustration: I called the below app test

---
title: "test"
output: html_document
date: "`r Sys.Date()`"
runtime: shiny
---

```{r, echo=FALSE}
selectInput(
  'Runs', label = 'Run:',
  choices = c("W", "S", "L", "F"), selected = "F", multiple = TRUE
)

selectInput(
  'Years', label = 'Year:',
  choices = c(2012, 2013), selected = 2012, multiple = TRUE
)

sliderInput(inputId =  "Yearslider",
          label = "Years to plot",
          #sep = "",
          min = as.Date("2012-01-01"),  
          max = as.Date("2013-04-10"),  #This dataset only has data up to 2013-04-08
          step = 30,
          value = c(as.Date("2012-01-09"), as.Date("2012-01-13")))
```

It works as expected if I run it by clicking the Run Document option in Rstudio. However, if I run it manually by typing: render("test.rmd", "html_document") my slider input control dissapears and turns into a input box like rectangular control and my first two controls lose their width and become really narrow. What am I missing?


Solution

  • render creates a static document i.e. not a running shiny app. You need to use rmarkdown::run("test.Rmd").