Summary table bug on Plot/Statistics tab
Opened this issue · 4 comments
Was unsure if I introduced bug while fixing other parts but check by switching to a previous SHA before I did any work and the bug is still present. When you click on the summary tab in Tab 5 Plot/Statistics the app throws an error. Tried various stations-variable combinations and it throws the error. The error is pasted below
Warning in survreg.fit(X, Y, weights, offset, init = init, controlvals = control, :
Ran out of iterations and did not converge
Warning: Error in <-: 'names' attribute [4] must be the same length as the vector [0]
138: .local
137: mean
135: .fun
134: <Anonymous>
132: llply
131: ldply
130: plyr::ddply
129: wqbc::summarise_wqdata
124: <reactive> [/Users/aylapearson/Applications/shinyrems/R/mod_results.R#188]
108: summary_table
105: exprFunc [/Users/aylapearson/Applications/shinyrems/R/mod_results.R#199]
104: widgetFunc
103: ::
htmlwidgets
shinyRenderWidget
102: func
89: renderFunc
88: renderFunc
84: renderFunc
83: output$results_ui_1-table
2: shiny::runApp
1: shinyrems::run_ems_app [/Users/aylapearson/Applications/shinyrems/R/run_app.R#71]
Issue related to wqbc bcgov/wqbc#163
This is occurring due to the edge cases when all the values are censored or only a single value remains for the site. I think that we can change the function to output NA's instead of an error message. That will allow sites/chemicals that have no values to have NA's displayed in the row and not cause an error so the table can generate.
Instead of an error that causes the whole tab to fail you would generate a table like this that displays each site/chemical
# A tibble: 2 × 14
Variable EMS_ID n ncen min max mean median lowerQ upperQ sd se lowerCL upperCL
<chr> <chr> <int> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 Nitrogen Total 0200016 3 0 0.754 0.949 0.849 0.845 0.793 0.901 0.0799 0.0461 0.763 0.944
1 Nitrogen Total 0478416 NA NA NA NA NA NA NA NA NA NA NA