I'm fairly new to Rshiny and looking for some help to understand how to create a Function that uses parameters that a user will select from the slider values on the app. The ultimate goal is generate a csv file which can be used to plot the function. This is what I have so far:
library(shiny)
ui <- fluidPage(
titlePanel( p ("title text", style = "color:#3474A7")),
sidebarLayout (
sidebarPanel(
sliderInput("Pop", "Pop Biomass:",
min = 0, max = 1000,
value = 651.7, step=0.1),
sliderInput("Rate", "slope:",
min = 0, max = 10,
value = 0.8, step=0.1),
sliderInput("Shape", "Sigmoid Shape:",
min = 0, max = 10,
value = 0.9, step=0.1),
sliderInput ("Area", "Activity:",
min = 0, max = 10000,
value = 180, step=20),
sliderInput("Time", "Age:",
min = 1, max = 50,
value = 2, step=1)
),
mainPanel( # Output: Table summarizing the values entered ----
tableOutput("values")
)))
Mod = function(A, b2, b3, R, x) {R *(A * exp(-b2 * b3 ^x))}
server()
server <- function(input, output){
sliderValues <- reactive({
data.frame(
Name = c("Pop",
"Shape",
"Rate",
"Area",
"Time"),
Value = as.character(c(input$Pop,
input$Shape,
input$Rate,
input$Area,
input$Time)),
stringsAsFactors = FALSE)
})
output$values1 <- renderTable({
sliderValues()
})
output$values<- renderTable({(Mod(input$Pop,input$Shape,input$Rate,input$Area,input$Time))
})}
shinyApp(ui = ui, server = server)
I'm not sure how to make the function use the slider values to run the specified function. Once it does that I want that function to run for all the years (Time-50 years) and generate an output-a csv output with two columns: Mod (y-axis) and Time (x-axis) which can be plotted to show the growth over time.