A shiny
Environments and data.
We will walk through at least one example as time permits.
docker build
docker push
This can be tricky with M1 macs as some images do not play nicely. NB: I am just beginning to explore this because it did not occur to me that it would be an issue from my Intel workstation.
Start with:
library(shiny)
library(dplyr)
ui <- ...
server <- ...
shinyApp(ui, server)
and the steps will fill in a ui
and server
tidy
evaluationlibrary(shiny)
library(dplyr)
ui <- fluidPage(
selectInput("var", "Sort by", choices = names(mtcars)),
checkboxInput("desc", "Descending order?"),
tableOutput("data")
)
server <- function(input, output, session) {
sorted <- reactive({
if (input$desc) {
arrange(mtcars, desc(.data[[input$var]]))
} else {
arrange(mtcars, .data[[input$var]])
}
})
output$data <- renderTable(sorted())
}
shinyApp(ui, server)
req
. What does it do?Why reactivity?
It started with VisiCalc…
The reactive graph is worth playing with. Due to modern defaults in RStudio, the workflow is a bit tricky. We will have to run the app in the console.
Run it and close it to get this.
Reactives, single and plural
Pay very close attention to 15.3 on observe
versus observeEvent
. The example in 16.3.3…
library(shiny)
reactiveConsole(TRUE)
x <- reactiveVal(1)
y <- observe({
x()
observe(print(x()))
})
x(2)
x(3)
x(2)
Isolate is not all that common because the behavior is embedded in two common tools:
on.exit()
15.5.2 and the importance of timing. Using on.exit
Two that are related.
The timer
It is quite easy to get carried away and muddle the flow.
Communicating With Data: Week 11 (3 Apr 2023)