Created
August 19, 2013 18:51
-
-
Save ChrisBeeley/6272654 to your computer and use it in GitHub Desktop.
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
#################################### | |
##### minimal example - server.R ### | |
#################################### | |
library(shiny) # load shiny at beginning at both scripts | |
shinyServer(function(input, output) { # server is defined within these parentheses | |
output$textDisplay <- renderText({ # mark function as reactive and assign to | |
# output$textDisplay for passing to ui.R | |
paste0("You said '", input$comment, # from the text | |
"'. There are ", nchar(input$comment), # input control as | |
" characters in this." # defined in ui.R | |
) | |
}) | |
}) |
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
############################## | |
### minimal example - ui.R ### | |
############################## | |
library(shiny) # load shiny at beginning at both scripts | |
shinyUI(pageWithSidebar( # standard shiny layout, controls on the left, output on the right | |
headerPanel("Minimal example"), # give the interface a title | |
sidebarPanel( # all the UI controls go in here | |
textInput(inputId = "comment", # this is the name of the variable- this will be passed to server.R | |
label = "What would you like to say?", # display label for the variable | |
value = "" # initial value | |
) | |
), | |
mainPanel( # all of the output elements go in here | |
h3("This is you saying it"), # title with HTML helper | |
textOutput("textDisplay") # this is the name of the output element as defined in server.R | |
) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment