From the course: Building Data Apps with R and Shiny: Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

What belongs in the server.R file?

What belongs in the server.R file?

From the course: Building Data Apps with R and Shiny: Essential Training

Start my 1-month free trial

What belongs in the server.R file?

- [Instructor] The server.R file is the brains of your Shiny app. It's the only file within which R code is allowed to run in your Shiny app. The server.R file therefore contains your data wrangling, modeling, and data visualization code. Because the server.R file is where the work of the Shiny app is done, it's usually significantly larger and more complex than the UI.R file, and so, you'll spend most of your time writing the server.R file of your app. Often, it's necessary to create pull-down menus in your UI that are populated with values from a data set selected in a server.R file. For instance, if your data concerns all box office hits in the last year, you'll want to pull in the names of these films from a data file instead of manually typing them into your Shiny app. This cannot be done in the UI.R file. Instead, you must update your input widgets server-side with the updateSelectInput function and its values. It's often desirable to prevent users from seeing empty charts or…

Contents