How can I execute an R script without having to stop Shiny.

Hello. I have created an R script that queries an API and stores the results in a dataframe. I then have several computations that run against the dataframe and the results are then rendered in a Shiny app. The only issue is that after 5 or so minutes the data is stale. I then have to stop the Shiny app and execute the R script again. Rinse and repeat. It's my understanding that while Shiny is running, nothing else can be executed in R. Am I wrong? This seems like a huge limitation if R can't actively query for fresh data while rendering the results in Shiny. I am looking for suggestions for how to accomplish what I have described. Perhaps R isn't the best solution and I should go another route?

I think you should separate the data processing pipeline from the presentation layer which is the shiny app, also, running shiny interactively is only meant for development not for deployment.

If you have more specific questions about this we can give them a try

@andresrcs . I am currently just using RStudio on a Windows 10 machine. Will building an RStudio Server, to host the data processing, and then using RStudio to launch the Shiny app work? I am in uncharted territory so forgive my ignorance.

You don't need RStudio Server to run a shiny app, or an R script for that matter. There are many deployment patterns for shiny apps but I can't recommend any particular one with such little information. Can you give more details about the intended use cases for your app?

It is strictly for personal use. I have written several R scripts (depending upon the category of data) that collects data from a REST API using httr and jsonlite. The data is then made tidy and saved in a number of dataframes (again based upon the category of the data). Several computations are then made against these dataframes. The results of all dataframes are then rendered to me via Shiny. I am able to select which dataset using the selectInput function.

I think you could schedule the execution of your Rscripts producing clean "ready to use data sets" and make your shiny app read from them using something like reactivePoll() to refresh the data source as frequently as needed.

Awesome! Just by glancing at the documentation this looks promising! I’ll report back in a while.

I had no idea that Shiny is as powerful as it is. I am now able to access an API, perform calculations and lastly render the data to my web browser with relative ease. I obviously have much to learn! Thank you @andresrcs

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