Check if interactive markdown is being run on Shiny Server

277 Views Asked by At

I want to write some R markdown templates which the user can choose to either save to the hard disk as an HTML document or run interactively through Shiny Server.

I think I need some way to check which of the modes the Rmd file is being executed through ( rendered to HTML or Shiny Server ) and accordingly decide whether I want the results to be static images, etc. or whether I want interactive Shiny elements.

Is there any way to achieve this?

PS: I tried to play around with the answers to this question how to tell if code is executed within a knitr/rmarkdown context? but wasn't able to get it.

1

There are 1 best solutions below

0
On BEST ANSWER

Right now the best way to do this is to ask knitr what the current runtime is. To check for runtime: shiny you'd use:

identical(knitr::opts_knit$get("rmarkdown.runtime"), "shiny")