I would like to write a Gui and Server, using Shiny, so that an integer is read and after clicking the bottom my function should be called and the output should appear in dashboard (shiny-GUI)
if (interactive()) {
ui <- fluidPage(
numericInput("obs", "your number:", 10, min = 1),
actionButton("do", "Print the Result")
)
# my function
calculate<-function(x){y<-x*x
if(y<24){print("the value is less than 5")}
else
{print("the value is greater than 5")}
}
# server
server <- function(input, output, session) {
observeEvent(input$do, {
output$value <- renderText({ input$calculate(obs) })
})
}
# call server
shinyApp(ui, server)
}
I just tried it in a simple example, however the code dose not work!
How can one call a function in server by clicking an action bottom generally?