COHHIO / ryha

R Shiny app for analyzing COHHIO Youth Homelessness Data
GNU Affero General Public License v3.0
8 stars 1 forks source link

App errors at Referral Source chart for some filters #56

Open mthomas-ketchbrook opened 1 year ago

mthomas-ketchbrook commented 1 year ago

The "Referral Source" bar chart at the bottom of the "Services" page is throwing an error with this specific combination of filters:

In the shinyapps.io server logs, we see the following error message:

2023-09-26T15:32:15.288952+00:00 shinyapps[7831250]: Warning: Error in [[: subscript out of bounds
2023-09-26T15:32:16.294976+00:00 shinyapps[7831250]:   115: <Anonymous>
2023-09-26T15:32:16.301111+00:00 shinyapps[7831250]:   114: echarts4r::e_flip_coords
2023-09-26T15:32:16.306664+00:00 shinyapps[7831250]:   111: ::
2023-09-26T15:32:16.312386+00:00 shinyapps[7831250]: htmlwidgets
2023-09-26T15:32:16.319690+00:00 shinyapps[7831250]: shinyRenderWidget [/srv/connect/apps/cohhio-youth-data-dashboard/R/mod_services.R#287]
2023-09-26T15:32:16.327037+00:00 shinyapps[7831250]:   110: func
2023-09-26T15:32:16.332692+00:00 shinyapps[7831250]:    97: renderFunc
2023-09-26T15:32:16.339038+00:00 shinyapps[7831250]:    96: output$services_1-referral_bar_chart
2023-09-26T15:32:16.345789+00:00 shinyapps[7831250]:    15: <Anonymous>
2023-09-26T15:32:16.352236+00:00 shinyapps[7831250]:    13: fn
2023-09-26T15:32:16.358830+00:00 shinyapps[7831250]:     8: retry
2023-09-26T15:32:16.364677+00:00 shinyapps[7831250]:     7: connect$retryingStartServer
2023-09-26T15:32:16.371639+00:00 shinyapps[7831250]:     6: eval
2023-09-26T15:32:16.377851+00:00 shinyapps[7831250]:     5: eval
2023-09-26T15:32:16.383382+00:00 shinyapps[7831250]:     4: eval
2023-09-26T15:32:16.391042+00:00 shinyapps[7831250]:     3: eval
2023-09-26T15:32:16.396621+00:00 shinyapps[7831250]:     2: eval.parent
2023-09-26T15:32:16.402849+00:00 shinyapps[7831250]:     1: local

This looks like it's a data issue in the database, and not an issue when there is no data to display; in the latter case, when using other filters, we correctly see a "No data to display" message in the bar chart box.

IvanM26 commented 1 week ago

After further inspection, the problem is related to the presence of NA values in the filtered referral source data for the column being charted.

Our current logic shows the message "No data to display" when the dataset has no rows. In this case, the data has rows, but the charted column has NA values (which are filtered in a subsequent step). For that reason, the chart then tries to create a chart with no data.

I can think of two possible solutions:

What do you think? @mthomas-ketchbrook @trevinflick

mthomas-ketchbrook commented 1 week ago

Let's pursue Option 1 -- thank you!