0

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.

Community
  • 1
  • 1
TheComeOnMan
  • 12,535
  • 8
  • 39
  • 54

1 Answers1

0

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")
Konrad
  • 17,740
  • 16
  • 106
  • 167
JJ Allaire
  • 556
  • 3
  • 3