Adding inputs
Inputs are Shiny's way of allowing users to interact with an app. For example, textInput()
is used to let the user enter text and numericInput()
lets the user select a number. In the next chapter we will see many other types of inputs.
To add an input to your app, simply add the input function inside fluidPage()
. Recall from the video that all input functions have the same first two arguments: inputId
and label
.
Este ejercicio forma parte del curso
Case Studies: Building Web Applications with Shiny in R
Instrucciones del ejercicio
- Define the UI for the Shiny application.
- Create a numeric input with ID "age" and a descriptive label of "How old are you?".
- Create a text input with ID "name" and a label of "What is your name?".
Ejercicio interactivo práctico
Prueba este ejercicio completando el código de muestra.
library(shiny)
# Define UI for the application
ui <- ___(
# Create a numeric input with ID "age" and label of
# "How old are you?"
numericInput(___, ___, value = 20),
# Create a text input with ID "name" and label of
# "What is your name?"
___(___, ___)
)
# Define the server logic
server <- function(input, output) {}
# Run the application
shinyApp(ui = ui, server = server)