library(shiny)ui<-fluidPage(sliderInput("x", label ="If x is", min =1, max =50, value =30),
"then x times 5 is",
textOutput("product"))server<-function(input, output, session){output$product<-renderText({# Fixed errorinput$x*5# by adding input$ })}shinyApp(ui, server)
library(shiny)ui<-fluidPage(sliderInput("x", label ="If x is", min =1, max =50, value =30),
sliderInput("y", label ="and y is", min =1, max =50, value =30),
"then x times y is",
textOutput("product"))server<-function(input, output, session){output$product<-renderText({input$x*input$y})}shinyApp(ui, server)
library(shiny)ui<-fluidPage(sliderInput("x", "If x is", min =1, max =50, value =30),
sliderInput("y", "and y is", min =1, max =50, value =5),
"then, (x * y) is", textOutput("product"),
"and, (x * y) + 5 is", textOutput("product_plus5"),
"and (x * y) + 10 is", textOutput("product_plus10"))server<-function(input, output, session){# Add this reactive expression to reduce # amount of duplicated codeproduct<-reactive({input$x*input$y})output$product<-renderText({product()})output$product_plus5<-renderText({product()+5})output$product_plus10<-renderText({product()+10})}shinyApp(ui, server)
What’s new is the additional calculation where 5 and 10 were added to the product and the outputs rendered as text.