Run R code on app open to generate inputs



I have R code that I’m trying to make into a shiny app. Right now, it works by scraping data from the web using jsonlite and rvest. It gets names from different websites, and puts them into different categories based on HTML info on the site. It then outputs this data as a CSV. I can manipulate the data by moving each name to the category (column) that I want it in. Once the data in the CSV is arranged the way I want it, I run the rest of my R code.

In the shiny tutorial, everything seemed to be built around initial user inputs. How do I go about having the app initially run my R code to scrape web data, and then having it output the imported web data as options for the user to adjust before running the rest of my R code?


Is there any reason you can’t have the data scraping step happen in the code before you open the server function in your server.R file? I imagine you could also use observeEvent() in other places in the server function to update/refresh the data if necessary. You could then set up your UI interface where the user has to indicate when to run other parts of the code with buttons, inputs, etc.