library(shiny)
# Task:
#
# 1. Set the default text for the Enter name field to "Anon"
#
# 2. Add a label for the numericInput item asking the user to choose a number
#
# 3. Change the step size on the slider to 5
ui <- fluidPage(
titlePanel("Exercise 1.1"),
sidebarLayout(
sidebarPanel(
textInput(inputId = "user_name",
label = "Enter name"),
numericInput(inputId = "number_chosen",
label = NULL,
value = 15),
sliderInput(inputId = "slider",
label = "Choose another number",
min = 10,
max = 100,
value = 50),
),
mainPanel(
textOutput(outputId = "supplied_name"),
textOutput(outputId = "info"),
plotOutput(outputId = "density_plot", height = "300px", width = "400px")
)
)
)
server <- function(input, output, session) {
output$supplied_name <- renderText(paste0("Hello ", input$user_name))
output$info <- renderText(paste0("Your two numbers are ",
input$number_chosen,
" and ",
input$slider)
)
output$density_plot <- renderPlot({
hist(rnorm(n = input$number_chosen * input$slider),
main = paste0("rnorm(n = ", input$number_chosen*input$slider, ")"))
})
}
shinyApp(ui, server)