You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've come across an error that occurs with empty datasets. As per #452 , leaflet can handle empty data.frames. However, the labels seem to still have an error when encountering an empty character vector. I'll include an example modified from #452 (comment) below.
I would expect that when passing an empty data.frame and empty label vector, it would be treated in the same way as passing an empty data.frame by itself, (i.e., leaflet would fail to show any points). Obviously there are easy workarounds, but it might be nice to handle internally.
library("tidyverse")
library("leaflet")
library("sf")
my_points<- tibble(
lat= c(10,20,30),
lon= c(20,40,50),
labels= c("a", "b", "c")
)
my_sf<-my_points %>%
st_as_sf(coords= c("lon", "lat"))
# If I filter to a single value, everything works as expectedmy_sf %>%
filter(labels=="c") %>%
leaflet() %>%
addTiles() %>%
addCircleMarkers(label=my_sf %>%
filter(labels=="c")%>%
pull(labels))
# If I filter to an empty table, things also work as expectedmy_sf %>%
filter(labels=="d") %>%
leaflet() %>%
addTiles() %>%
addCircleMarkers()
# If I filter to an empty table, but include labels, I get an errormy_sf %>%
filter(labels=="d") %>%
leaflet() %>%
addTiles() %>%
addCircleMarkers(label=my_sf %>%
filter(labels=="d")%>%
pull(labels))
#> Error in sum(sapply(label, function(x) {: invalid 'type' (list) of argumentCreatedon2024-03-11with [reprexv2.0.2](https://reprex.tidyverse.org/)
The text was updated successfully, but these errors were encountered:
I've come across an error that occurs with empty datasets. As per #452 , leaflet can handle empty data.frames. However, the labels seem to still have an error when encountering an empty character vector. I'll include an example modified from #452 (comment) below.
I would expect that when passing an empty data.frame and empty label vector, it would be treated in the same way as passing an empty data.frame by itself, (i.e., leaflet would fail to show any points). Obviously there are easy workarounds, but it might be nice to handle internally.
The text was updated successfully, but these errors were encountered: