An attempt to amend the lecture code to calculate the length of the hypotenuse (of a right angled triangle) given the lengths of the adjacent and opposite. Hypotenuse = (Adjacent^2 + Opposite^2)^0.5
shinyServer(
function(input, output) {
output$Adjacent <- renderText({input$Adjacent})
output$Opposite <- renderText({input$Opposite})
output$Hypotenuse <- renderText({
input$goButton
isolate(paste(input$Adjacent, input$Opposite))
})
}
)
shinyUI(pageWithSidebar(
headerPanel("Shiny triangle!"),
sidebarPanel(
textInput(inputId="Adjacent", label = "Length Adjacent"),
textInput(inputId="Opposite", label = "Length Opposite"),
actionButton("goButton", "Calculate!")
),
mainPanel(
p('Output Adjacent'),
textOutput('Adjacent'),
p('Output Opposite'),
textOutput('Opposite'),
p('Output Hypotenuse'),
textOutput('Hypotenuse')
)
))