I'm trying to write a simple Shiny app that plots an exponential decay function where the user can input different values of lambda. Every variation I've tried results in "Error in rep(value, length.out = nrows) : attempt to replicate an object of type 'closure'." I've tried taking the advice from this thread, but haven't been able to resolve my issue.
library(shiny)
decay <- data.frame(days= seq(100, 0))
ui <- fluidPage(
sliderInput(inputId = "lambda",
label = "Choose a number",
value = 0.0, min = 0.0, max = 0.2),
plotOutput("lplot")
)
server <- function(input, output){
decay[[2]] <- reactive({
exp(-input$lambda*decay[[1]])
})
output$lplot <- renderPlot({
plot(decay())
})
}
shinyApp(ui = ui, server = server)
I'm brand new to Shiny, so I could be overlooking something pretty basic. Thanks for your help.
decay[[1]]
supposed to give? – SymbolixAU