I am trying to use the openairmaps and leaflet in R to add pollution plots on top of a leaflet map. Now I have already done this before, and produced the outcome I wanted, but that was almost 6 months ago and now the same code and data is no longer working. I am not aware of updates to openairmaps and I've tried to dig and see if the addPolarMarkers code (which is the function throwing the error) has changed, but it doesn't seem like it?
My data is air pollution data with a variety of variables, and is too lengthy to reproduce entirely, but I will show a basic version:
date | year | month | particle_size | concentration | wd | ws | LAT | LON |
---|---|---|---|---|---|---|---|---|
01 | 2021 | 01 | 10.8 | 192830 | 180 | 5 | 42 | -71 |
02 | 2021 | 01 | 6.4 | 45028 | 180 | 0 | 42 | -71 |
03 | 2021 | 01 | 20.9 | 47293 | 310 | 2 | 42 | -71 |
04 | 2021 | 01 | 295.2 | 33894 | 18 | 5 | 42 | -71 |
05 | 2021 | 01 | 365.1 | 173628 | 270 | 7 | 42 | -71 |
06 | 2021 | 01 | 49.2 | 102983 | 210 | 10 | 42 | -71 |
07 | 2021 | 01 | 65.7 | 473628 | 180 | 9 | 42 | -71 |
All of these values are numeric.
So the code is just creating a basemap and adding a polar plot from this site on top:
m <- leaflet() %>%
addTiles() %>% # Add default OpenStreetMap map tiles
addMarkers(lng=data$LON, lat=data$LAT, popup="The birthplace of R")
m %>% addProviderTiles(providers$CartoDB.Voyager) %>%
addPolarMarkers(
data,
pollutant = "concentration",
fun=openair::polarPlot,
lng= "LON",
lat= "LAT",
#cols="jet",
#d.icon=120,
#popup="name",
#limits = c(0, 50000)
)
Every time I run this now I get this error:
Error in UseMethod("drop_na") :
no applicable method for 'drop_na' applied to an object of class "list"
I have tried to debug and this code goes wrong in the create_polar_marker() function within the addPolarMarker() function. For some reason the data input is a list of label & dummyvariable for create_polar_marker(). My understanding of how this functions under the hood is very minimal so I am not clear on how this was generated.
If anyone has any insight that would be SO helpful! Thank you!