Skip to content

Instantly share code, notes, and snippets.

@Inkimar
Last active June 2, 2021 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Inkimar/8b71092b663be1bed167dda7ad084349 to your computer and use it in GitHub Desktop.
Save Inkimar/8b71092b663be1bed167dda7ad084349 to your computer and use it in GitHub Desktop.
Server.R ( och shiny)
#library(shiny) #load shiny at beginning of both scripts
shinyServer(function(input, output) { # define application in here
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
})
})
@Inkimar
Copy link
Author

Inkimar commented Jul 30, 2020

ui.R -> a minimal example

shinyUI(fluidPage( # flexible layout function

Title

titlePanel("Den minimala applikationen"),

sidebarLayout(
sidebarPanel(
textInput(inputId = "comment", # this is the name of the
# variable- this will be passed to server.R
label = "Säg något", # display label for the variable
value = "" # initial value

  )),

# Show a plot of the generated distribution
mainPanel( # main output configuration
  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