Highcharter Map Not Producing Same Results on shinyapp.io as Local

Hello!

I have a flexdashboard using a combination of rvest and highcharter to scrape data from a site and produce maps of the US with color shading for population. The code itself runs perfectly, but the problem is that a few of the states on my shinyapp.io site appear blank. All of the other color-coded states have the correct values, but the blank states should also contain values.

Link to shinyapps.io dashboard: https://rsh52.shinyapps.io/GV_Dashboard/

Here is an image of what the local dashboard looks like, with values for Delaware, New Hampshire, and Alaska:

Here is what the shinyapps.io dashboard looks like, missing values for those states:

And in case it helps, here is the full GitHub repo: GitHub - rsh52/Gun_Violence_Dashboard: A dashboard that displays gun violence descriptive statistics via "mass shootings" in the United States and shooting incidents in the city of Philadelphia.

Any and all help appreciated! I'm unsure why this would occur and if it has something to do with the publishing process.

The map seems to be loading correctly on my end (tested in Safari, Chrome, Firefox). Data appears for Wyoming and Alaska. Either there is new data (a grim thought) or some changes were made. However, I don't see data for New Hampshire.

My guess is that there is missing data for states in a given time period and the mapping function doesn't know how to render the state. A default condition is likely needed before the data is added to the map. Might be worth adding some logic to check to see if there data for all 50 states for all time periods. If there isn't, then add NA or 0.

I noticed that the main file is executing the web scrapping script. It might be worth isolating the scrapping and cleaning process from the app as there might be some unforeseen issues down the line when the source is updated or changed. The scrapping script could be run on demand (i.e., in the app trigged by a button) or using a scheduler (i.e., daily, weekly, etc.).

Hope that helps!

Hi @dcruvolo! Thank you for your response. You may have actually opened a slightly updated version of the dashboard. Last night I added in elements of shiny to allow for date filtering and as a result the states then populated correctly. While I wanted to chalk this up to magic, I think you're correct and there might be some NA or faulty logic in the data itself which I'll check later.

That's a really good point though about the script isolation. I ran into an issue where one of the web services went down and the dashboard broke so that may be a worthwhile method to implement regardless.

Thanks so much!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.