I have a script called function.R which contains a function called my_function that generates an output.
my_function <- function(a, b, c) {
# code
}
How can I get the user to input values for a,b,c in a r shiny app and then these inputs can be delivered to my function.R script. I want the shiny app to take in the inputs for each of these values (a,b,c) and then send it to my function.R script so it can show the output of my function in the r shiny app.
My r shiny app is
library(shiny)
source("/Users/havekqnsc/Desktop/function.R")
ui <- fluidPage(
titlePanel("Function Output"),
numericInput("a", "a", value = ""),
numericInput("b", "b", value = ""),
textInput("c", "c", value = ""),
actionButton("Submit", "RunFunction")
)
server <- function(input, output) {
observeEvent(input$Submit, {
my_function()
})
}
shinyApp(ui, server)
observeEvent(input$Submit, {myfunction(a=input$a, b=input$b, c=input$c)})observeEvent. That way, you can simply pass the reactive to arenderTableto display it.