Reputation: 2367
I develop functions that take input
from Shiny. However in order to test those functions, I need to run them without Shiny. So I'd like to do something like this.
---
title: "My report that prints `input` variable in both reactive and static format"
# runtime: shiny # I want to be able programmatically to see when Shiny is running and when NOT
---
```{r}
library(shiny)
input0 <- list()
input0$typedDate <- "6/08/1935"
if (!is.shinyRunning()) {
print("Shiny is Not Running")
input <- input0
} else {
textInput("typedDate", "Enter Date:", "6 jul 1935")
}
renderPrint(input$typedDate)
Note, I tried using if (interactive())
, but it returns FALSE for report both with Shiny and without Shiny.
Upvotes: 3
Views: 560
Reputation: 84709
There's the isRunning
function in 'shiny'.
This function tests whether a Shiny application is currently running.
Upvotes: 7