A web app is a thing that updates based on user input/interaction.
Most web apps have two parts:
ui <- fluidPage(
## Title of the App
titlePanel(title = "App Title")
##SideBar layout
sidebarLayout(
sidebarPanel = sidebarPanel(),
mainPanel = mainPanel()
)
)pickerInput()server <- function(input, output, session){
# outputs
output$some_plot <- renderPlot({})
output$some_text <- renderText({})
output$some_table <- renderTable({})
# Reactives, events
}Reactive Source: User input that comes through a browser interface, typically. reactive sources are accesible through any input$x
Reactive conductor: An intermediate that depends on reactive sources, and/or updates reactive endpoints. Conductors are good for slow or expensive calculations, and are placed between sources and endpoints.
Reactive endpoint: output that typically appears in the browser window, such as a plot or a table of values. Are accesible through any output$y, and are observers, primarily used for their side effects, and not directly to calculate things.
Reactive expressions: reactive expressions are lazy and cached. the expression behaves just like a function but with two key differences:
Role
reactive() is for calculating values, without side effects.observe() is for performing actions, with side effectsDifferences
stop: The isolate({}) function allows to read a reactive value separately of the other inputs, then only the update will be place when the non-isolated input will be changed.
delay: In some situations we might want more explicit control to trigger the update. We can achieve this using eventReactive(). is used to create a calculated value that only updates in response to an event.
trigger: There are times when you want to perform an action in response to an event. We can achieve this with observeEvent(). Unlike eventReactive, observeEvent is used only for a side effects and it does not return any value.
CEM are great way to nudge users and to using the app correctly.
validate()need(logical expression (input), error message )shinyWidgetsGallery(): opens a pre-built Shiny app that allows you to explore these pre-built inputs and gives you the code for implementing them
bootstrapPage(): full page with no margins