Hi, and welcome to community.rstudio.com!
Without knowing how your shiny app.R
code is structured, it's a little difficult to give good guidance. Have you placed this inside a shiny app, or are you attempting to run just the code you've entered here?
To help you get the right help for your question, can you please turn it into a reprex (reproducible example)? This will ensure we're all looking at the same data and code. A guide for creating a reprex can be found here.
You may also find the "Shiny Apps" section of this page useful (though it seems a bit out of date, as it refers to ui.R
and server.R
instead of app.R
).