I'm working on a shiny app for a local school district that will display a flag for schools that shouldn't have recess based on air pollutant conditions. The app will filter for one specific day and I've added a column called recess that, based on air pollutants, is labelled either "Stay Inside!" or "Play On!". I've then created an icon list - a child playing icon for "Play on!" and a danger icon for "Stay Inside!".
Where I'm having trouble is with the function. I'm trying to get it to tell leaflet to display the child playing icon for the schools that can have recess that day and a danger icon for the schools that shouldn't have recess that day.
Warning messages:
1: In if (bad_air$recess == "Stay Inside") { :
the condition has length > 1 and only the first element will be used
2: In if (bad_air$recess == "Stay Inside") { :
the condition has length > 1 and only the first element will be used
3: In if (bad_air$recess == "Stay Inside") { :
the condition has length > 1 and only the first element will be used
Where am I going wrong? Any help is greatly appreciated!
Instead of taking elements from recess one at a time, it is asking if all recess from bad_air is equal to "Stay Inside". The warning will go away if you put update the function as below.
However, this will not get the view you described as the results from getrecessIcon(bad_air) is a matrix, where the icon argument is expecting an icon list. The code below can remove the getrecessIcon() and directly have dynamic icons based on recess column content.
You may consider converting your plain data frame to a {sf} data frame; it would make the leaflet call more concise. I am not sure I have not messed up your lat / lon data (this is literally middle of nowhere, in Russia to boot..)