I am writing an app that fits a zero curve to observed bond prices. The shiny GUI is specified as follows:
ui <- dashboardPage(
dashboardHeader(title = "Curve fit"),
dashboardSidebar(),
dashboardBody(
fluidRow(
box(title="Messages",textOutput("Messages")),
box(title = "...",
selectInput("curveType",
label = "CurveType",
choices = c("NSS","Cubic Spline")
)
),
fluidRow(
box(title="...",
plotOutput("curvePlot",width = "100%", height = "400px")
),
box(title="...",tableOutput("spreadTable"))
)
)
)
server <- function(input, output, session) {
curveType <- reactive(input$curveType)
refDate <- as.Date('2024-03-12')
output$Messages <- renderText({"Fitting curve..."})
# curve fit
verboseLevel <- 1
curveFit <- reactive(CurveFitting::fitCurve(
curveType(),bondBaseData_df,refDate,verboseLevel
))
output$Messages <- renderText({"Finished."})
output$spreadTable <- renderTable({curveFit()$.spreadDF})
output$curvePlot <- renderPlot({curvePlot(curveFit()$.zeroCurve)})
}
shinyApp(ui, server)
The first message “Fitting curve” never appears but the second message “Finished” does.
What could be the reason and is there something wrong with the code above?