Complete the code to create a basic Shiny app UI with a title.
ui <- fluidPage( [1]("My Shiny App") )
The titlePanel function adds a title to the Shiny app UI.
Complete the code to define the server function that outputs text.
server <- function(input, output) {
output$text <- renderText({
[1]("Hello, Shiny!")
})
}The renderText function is used inside the server to create text output.
Fix the error in the code to correctly display a numeric input in the UI.
ui <- fluidPage( numericInput([1], "Enter a number:", value = 10) )
The first argument of numericInput must be a string ID in quotes.
Fill both blanks to create a UI with a slider input and display its value as text.
ui <- fluidPage( sliderInput([1], "Choose a value:", min = 1, max = 100, value = 50), textOutput([2]) )
The slider input and the text output must share the same ID string to link input and output.
Fill all three blanks to create a Shiny app that shows the square of a numeric input.
ui <- fluidPage( numericInput([1], "Number:", value = 2), textOutput([2]) ) server <- function(input, output) { output[3] <- renderText({ input$num ^ 2 }) } shinyApp(ui, server)
The numeric input ID is "num". The text output ID is "result". The server output uses output$result to match the text output.