Last active
February 10, 2018 11:20
-
-
Save cecilialee/3999fb45275d19c4f883b221754e045a to your computer and use it in GitHub Desktop.
Access inputs and output values in Shiny. #r #shiny
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment