My data is :
counted<-structure(list(scientificName = c("<U+00D7>Calammophila baltica (Flugge ex Schrad.) Brand",
"<U+00D7>Calammophila baltica (Flugge ex Schrad.) Brand", "<U+00D7>Mahoberberis neubertii (Lem.) C.K.Schneid.",
"<U+00D7>Mahoberberis neubertii (Lem.) C.K.Schneid.", "Abacarus Keifer, 1944",
"Abacarus Keifer, 1944", "Abacarus Keifer, 1944", "Abacarus Keifer, 1944",
"Abacarus Keifer, 1944", "Abacarus Keifer, 1944", "Abacarus Keifer, 1944",
"Abacarus Keifer, 1944", "Abacarus Keifer, 1944", "Abacarus Keifer, 1944",
"Abacarus Keifer, 1944", "Abacarus Keifer, 1944", "Abacarus Keifer, 1944",
"Abacarus acutatus Sukhareva, 1985", "Abacarus acutatus Sukhareva, 1985",
"Abacarus acutatus Sukhareva, 1985"), verbatimScientificName = c("x Calammophila baltica",
"x Calammophila baltica", "Mahoberberis neubertii (hort. ex Lem.) C.K. Schneid.",
"Mahoberberis neubertii C. K. Schneid.", "Abacarus plumiger",
"Abacarus plumiger", "Abacarus plumiger", "Abacarus plumiger",
"Abacarus plumiger", "Abacarus plumiger", "Abacarus sp. 3 PL-2017",
"Abacarus sp. 4 PL-2017", "Abacarus sp. 6 PL-2017", "Abacarus sp. 7 PL-2017",
"Abacarus sp. MD-2009", "Abacarus sp. MD-2009", "Abacarus sp. MD-2009",
"Abacarus acutatus", "Abacarus acutatus", "Abacarus acutatus"
), year = c(2006, 2006, 2004, 2004, 2007, 2007, 2008, 2008, 2009,
2012, 2008, 2008, 2008, 2010, 2006, 2007, 2007, 2007, 2007, 2008
), decimalLatitude = c(54.369999, 54.68, 50, 50.049999, 52.110001,
52.110001, 52.560001, 52.669998, 52.709999, 52.459999, 52.93,
52.669998, 52.669998, 52.91, 52.279999, 52.110001, 52.27, 52.22,
52.27, 52.470001), decimalLongitude = c(18.73, 18.719999, 19.9,
19.916666, 17.549999, 17.57, 17.110001, 17.5, 16.25, 16.93, 15.94,
17.5, 17.5, 17.450001, 16.59, 17.57, 16.559999, 16.56, 16.540001,
16.93), count = c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 3L, 1L, 1L, 1L,
2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L)), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"), row.names = c(NA, -20L), groups = structure(list(
scientificName = c("<U+00D7>Calammophila baltica (Flugge ex Schrad.) Brand",
"<U+00D7>Calammophila baltica (Flugge ex Schrad.) Brand",
"<U+00D7>Mahoberberis neubertii (Lem.) C.K.Schneid.", "<U+00D7>Mahoberberis neubertii (Lem.) C.K.Schneid.",
"Abacarus Keifer, 1944", "Abacarus Keifer, 1944", "Abacarus Keifer, 1944",
"Abacarus Keifer, 1944", "Abacarus Keifer, 1944", "Abacarus Keifer, 1944",
"Abacarus Keifer, 1944", "Abacarus Keifer, 1944", "Abacarus Keifer, 1944",
"Abacarus Keifer, 1944", "Abacarus Keifer, 1944", "Abacarus Keifer, 1944",
"Abacarus acutatus Sukhareva, 1985", "Abacarus acutatus Sukhareva, 1985",
"Abacarus acutatus Sukhareva, 1985"), verbatimScientificName = c("x Calammophila baltica",
"x Calammophila baltica", "Mahoberberis neubertii (hort. ex Lem.) C.K. Schneid.",
"Mahoberberis neubertii C. K. Schneid.", "Abacarus plumiger",
"Abacarus plumiger", "Abacarus plumiger", "Abacarus plumiger",
"Abacarus plumiger", "Abacarus sp. 3 PL-2017", "Abacarus sp. 4 PL-2017",
"Abacarus sp. 6 PL-2017", "Abacarus sp. 7 PL-2017", "Abacarus sp. MD-2009",
"Abacarus sp. MD-2009", "Abacarus sp. MD-2009", "Abacarus acutatus",
"Abacarus acutatus", "Abacarus acutatus"), year = c(2006,
2006, 2004, 2004, 2007, 2008, 2008, 2009, 2012, 2008, 2008,
2008, 2010, 2006, 2007, 2007, 2007, 2007, 2008), decimalLatitude = c(54.369999,
54.68, 50, 50.049999, 52.110001, 52.560001, 52.669998, 52.709999,
52.459999, 52.93, 52.669998, 52.669998, 52.91, 52.279999,
52.110001, 52.27, 52.22, 52.27, 52.470001), .rows = structure(list(
1L, 2L, 3L, 4L, 5:6, 7L, 8L, 9L, 10L, 11L, 12L, 13L,
14L, 15L, 16L, 17L, 18L, 19L, 20L), ptype = integer(0), class = c("vctrs_list_of",
"vctrs_vctr", "list"))), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -19L), .drop = TRUE))
but Im trying to create the pop up message with count number with:
library(leaflet)
library(dplyr)
leaflet(data = counted) %>% addTiles() %>%
addMarkers(~decimalLongitude,~decimalLatitude, popup = ~as.character(paste("Name:",scientificName,"-","Count:",count,sep="\n")))%>%
setView(lng = 19.0, lat = 52.0, zoom = 6) # Center over Poland
and get:
Warning: Error in eval: object 'Count' not found
I think you are looking for a variation of
library(leaflet)
library(dplyr)
# copy-pasted from https://rstudio.github.io/leaflet/articles/markers.html without careful consideration
greenLeafIcon <- makeIcon(
iconUrl = "https://leafletjs.com/examples/custom-icons/leaf-green.png",
iconWidth = 38, iconHeight = 95,
iconAnchorX = 22, iconAnchorY = 94,
shadowUrl = "https://leafletjs.com/examples/custom-icons/leaf-shadow.png",
shadowWidth = 50, shadowHeight = 64,
shadowAnchorX = 4, shadowAnchorY = 62
)
leaflet(data = counted) %>%
addTiles() %>%
setView(lng = 19.0, lat = 52.0, zoom = 6) %>%
addMarkers(~decimalLongitude, ~decimalLatitude,
icon = greenLeafIcon, popup = ~paste("Name:", scientificName, "<br> Count:", count))