2

I have a small shiny app in shinyapps.io with a database that stores products. I want to re-deploy the app everytime the database gets new data so the shiny app shows up-to-date products. Since this will happen quite often, I want to see the progress everytime the app gets re-deployed. How can I put a progress bar at the beginning and end of my R script? Most of the examples I see online are with loops but I couldn't find anything that work with scripts. Example below:

#Start of progress bar
library(rsconnect)
rsconnect::setAccountInfo(name='joe',
                          token='1AC4D3B9061349DC',
                          secret='euAUwk6tOJg4IMztzSz3oBz')

rsconnect::deployApp(account = 'joe', 
                     appDir = file.path(getwd()),
                     appFiles = c("app.R", "deer.db", "setPlace.R"), 
                     appId = "11278568") 
#End of progress bar
6
  • 2
    Why do you think you need to redeploy an app in order to update a table from a database? Also you can't get a progress bar for a process that calls one function - there is no way of telling how long it is going to take, so no way of updating a progress bar in a meaningful way. Commented Aug 12 at 17:08
  • I need to update the database because it is bundled with my shiny app in the server. Commented Aug 12 at 17:10
  • 2
    "I need to update the database because it is bundled with my shiny app": I feel this means you have an XY problem. Host the database remotely. Then there is no need to bundle it with the app. The app will automatically pick up changes to the database without the need to redeploy. Commented Aug 12 at 19:01
  • I checked both options and I ended up including the database instead of hosting it on a different server because I still had to manually go to the server where the database resides and update. Including it with the shiny app I can put a scheduler in the middle of the night to check if my local database has new records. If it does, then the shiny app redeploys with the new fresh records. I haven't had any problems at all. Although I like the idea of hosting the database somewhere else to see if is feasible time-wise. Commented Aug 12 at 20:26
  • A literal search on google or similar for "R" progress bar returns many good really good examples, including the progress package. While most of the examples do show for loops, there's every indication that you can use pb$tick() in as many places as you need. I get that you said you found some online and they all demonstrated loops, I don't see anything in progress, progressr, nor even in utils::txtProgressBar that suggests it must be used inside of a loop. Commented Aug 13 at 1:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.