Inserting a dynamic data table
Now we will add a dynamic table with the data we simulated in the previous chapter, so first of all, we need to bring that data into the application, and we do so with the line shown below. You should place this data-loading line above the ui
object in your app. This way, it will only be run once, when starting up the Shiny application, as any code that would normally be run when executing an R script:
ORIGINAL_DATA <- read.csv("../chapter-09/data.csv", stringsAsFactors = FALSE)
At this point, we need to introduce the DT
package. It provides an easy way to create dynamic tables for Shiny applications. Since we will reference it through its package name, we don't need to load it with library(DT)
. Referencing it by its package name helps us separate the native Shiny functions from those that come from external packages.
To implement this, we need to modify the server
function we had not touched up to this point. We need to introduce some logic into it that will...