Running R Shiny App within RStudio versus a Batch file or Command Prompt


I created a Shiny Dashboard App within RStudio and when I run the dashboard, within RStudio, I have no problems -- the dashboard pops up as expected.

I created a shortcut to run the app using a batch file, I simply followed this example. When I execute the batch file, a browser pops up and loads the dashboards but the browser is grayed out and the data is not populated in the dashboard.

My batch file code: "C:\Program Files\R\R-4.0.4\bin\R.exe" CMD BATCH "run.r" which executes the run.r file that subsequetly runs a ui.r and server.r file. The run.r script is as follows:

folder_address = 'C://test_app'
runApp(folder_address, launch.browser=TRUE) 

I tried a different method to create a shortcut, which was simply creating a command prompt script which when executed immediately errors out and says:

Package 'htmltools' version cannot be unloaded: Error in unloadNamespace(package) : namespace 'htmltools' is imported by 'rmarkdown', 'shinydashboard', 'flexdashboard', 'shiny' so cannot be unloaded

I figured I could solve the htmltools issue by reinstalling each package mentioned in the error but that just that didn't work and the error returned.

My command prompt script: C:\Program Files\R\R-40~1.4\bin\Rscript.exe" -e "shiny::runApp('C:/test_app', launch.browser = TRUE)"

The issue doesn't seem to be with my actual r code but rather my batch file/ command prompt script or how the command is communicating with R. If anyone has any thoughts/suggestions I'd really appreciate the help.

I'd recommend using Rscript.exe instead of R.exe to run a R script file.

A mĂ­ me sirve lanzar la app especificando el puerto y el host
Algo como esto,

R -e shiny::runApp('myapp.R', port=8080, host='')

Y listo, se monta la app, accedes a ella visitando tu ip por el puerto que especĂ­ficaste.

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