Executing a shiny application from powerpoint

Hello All

I teach basic of Financial Management using native PowerPoint and Excel. Excel is used to show the various computations. Explaining the computations using excel is sub-optimal in the classroom setting. I have created a shiny application (app.R) where all the quantitative calculations are done. I would like to start this shiny application from appropriate slides in the presentation. Shiny app will need to be local (can't host it on any cloud infrastructure)

Can somebody guide me about how to accomplish this?

Thanks

Hi,

Welcome to the RStudio community!

There are several ways you can go about this:

OPTION 1 - Easy but more manual stuff

  1. Open RStudio and run the app in your browser (so not in window)
  2. Copy the address link and close the browser, but leave the app running in RStudio
  3. Paste the link as hyper link in the appropriate slide (port will change every time at random)
  4. Run PowerPoint, and when clicking the link, the browser will open with the app
  5. Stop the app in RStudio when finished with presentation

OPTION 2 - Second script, only edit PowerPoint once

  1. Create an helper script to start your Shiny app (see below). Make sure to set a port
  2. Paste the link as hyper link in the appropriate slide (will be http://127.0.0.1:<port>)
  3. Run the helper script in R studio or start it as a background job (Jobs tab)
  4. Run PowerPoint, and when clicking the link, the browser will open with the app
  5. Stop the app in RStudio when finished with presentation

OPTION 3 - Start with batch script

  1. Create an helper script to start your Shiny app (see below). Make sure to set a port
  2. Create a Windows batch script (.bat) that starts the helper script (see below)
  3. 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
  4. 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

2 Likes

This topic was automatically closed 60 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.