Hi,
I would like my Shiny app to know whether it is served by:
- Rstudio in a RStudio panel
- Rstudio in a web browser tab
- Any remote server
Using an interactive() call returns TRUE for options 1 and 2, and FALSE for 3... how can I distinguish between 1 and 2?
Thanks
library(shiny)
ui <- bootstrapPage(
verbatimTextOutput('condition')
)
server <- function(input, output) {
output$condition <- renderPrint({ interactive() })
}
shinyApp(ui = ui, server = server)
barret
2
Give the code below a try:
rstudioMode <- tryCatch({
rstudioapi::versionInfo()$mode
},
error = function(e) {
"not_found"
}
)
The code is wrapped in a tryCatch as versionInfo
likes to throw if it is not in RStudio.
Hi @barret
rstudioMode
has the same value (that is 'server'
) in cases 1 and 2 described in my original post. So, this has the same problem as interactive()
.
system
Closed
5
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.