Access inputs and output values in Shiny. #r #shiny
# Using double brackets
## Understanding inputs and outputs as a list. Their values are accessable via double brackets.
library(shiny)
ui = basicPage(
textInput("txt", "Text"),
textOutput("ptxt")
)
server = function(input, output) {
output[["ptxt"]] <- renderText({ input[["txt"]] })
}
shinyApp(ui, server)
# Using dollar sign
## Most convenient usage. However, there'll be situations when this is not useful.
library(shiny)
ui = basicPage(
textInput("txt", "Text"),
textOutput("ptxt")
)
server = function(input, output) {
output$ptxt <- renderText({ input$txt })
}
shinyApp(ui, server)