inst/shiny_tipsae/server_files/results_estimates_server.R

### Create reactive objects --------

estimates <- shiny::reactive({
  if (is.null(res_model())) {
    return(NULL)
  } else {
    tipsae::extract(x = res_model()$summary)
  }
})


### Sources for plots -----

source("server_files/plots/results_estimates_map.R", local = TRUE)
source("server_files/plots/results_estimates_cat.R", local = TRUE)
source("server_files/plots/results_estimates_traj.R", local = TRUE)



### Observe expressions -------
shiny::observe({
  if (!is.null(estimates()$out_of_sample)) {
    shinyjs::show(id = "panel_tab_oos")
  }else{
    shinyjs::hide(id = "panel_tab_oos")
  }
})



### Text / table outputs ------

output$tab_is <- DT::renderDT(
  options = list(pageLength = 10, scrollX = TRUE), {
    estimates()$in_sample
  })


output$tab_oos <- DT::renderDT(
  options = list(pageLength = 10, scrollX = TRUE), {
    estimates()$out_of_sample
  })


output$download_estimates <- shiny::downloadHandler(
  filename = function(){"Model_estimates.csv"},
  content = function(fname){
    tipsae::export(x = estimates(), file = fname)

  }
)

Try the tipsae package in your browser

Any scripts or data that you put into this service are public.

tipsae documentation built on Sept. 13, 2024, 5:07 p.m.