LoslegenKostenlos loslegen

"Hello, World" app output (UI/Server)

To finish up your "Hello, world" app, you'll have to actually display the text that's input.

Recall this is how you construct an output from an input:

# Render output y using input x
output$y <- renderText({
  input$x
})

shiny has been pre-loaded for you.

By the end of this exercise, your app should look like this: Web app that asks a user to enter a name and then displays "Hello name"

If you get an error message resembling Parsing error in script.R:4:3: unexpected symbol, it is very likely that you have forgotten to use a comma to separate the arguments to one of the functions.

Diese Übung ist Teil des Kurses

Building Web Applications with Shiny in R

Kurs anzeigen

Anleitung zur Übung

  • Server: Create an output named 'greeting' that displays "Hello, Kaelen" when Kaelen is input as the name.
  • UI:: Display the output in the UI. Be sure to add a comma after textInput(), before adding more code.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

ui <- fluidPage(
	textInput("name", "What is your name?")
	# CODE BELOW: Display the text output, greeting
    # Make sure to add a comma after textInput()

)

server <- function(input, output) {
	# CODE BELOW: Render a text output, greeting

  
  
}

shinyApp(ui = ui, server = server)
Code bearbeiten und ausführen