Hi,
Welcome to the RStudio community!
There are several ways you can go about this:
OPTION 1 - Easy but more manual stuff
- Open RStudio and run the app in your browser (so not in window)
- Copy the address link and close the browser, but leave the app running in RStudio
- Paste the link as hyper link in the appropriate slide (port will change every time at random)
- Run PowerPoint, and when clicking the link, the browser will open with the app
- Stop the app in RStudio when finished with presentation
OPTION 2 - Second script, only edit PowerPoint once
- Create an helper script to start your Shiny app (see below). Make sure to set a port
- Paste the link as hyper link in the appropriate slide (will be http://127.0.0.1:<port>)
- Run the helper script in R studio or start it as a background job (Jobs tab)
- Run PowerPoint, and when clicking the link, the browser will open with the app
- Stop the app in RStudio when finished with presentation
OPTION 3 - Start with batch script
- Create an helper script to start your Shiny app (see below). Make sure to set a port
- Create a Windows batch script (.bat) that starts the helper script (see below)
- Copy either the link to the batch script or the link to the Shiny app in PowerPoint
- The link to the batch script will start R, start the server and open the app (if launch.browser = T). PowerPoint however will throw some warnings about opening unknown scripts, which might be unwanted during presentation
- If using the link to the app itself, you have to run the batch script before you start the presentation (and set launch.browser = F so it doesn't run the app immediately). When you click the link, the browser will open and show the app
- After the presentation, close the batch script (will be running in CMD window) to stop R and the server.
Helper Script (runShinyApp.R)
library(shiny)
#The path is to the folder, not the app file (app should be called app.R or server.R/ui.R)
runApp("pathToShinyAppFolder/", launch.browser = T, port = 1234)
Batch file (startApp.bat)
Find the correct path the the Rscript.exe (depends on your R version and install path)
"C:\Program Files\R\R-4.0.2\bin\Rscript.exe" "pathToShinyAppFolder\runShinyApp.R"
Hope this helps,
PJ