I have rows of data with duplicate lat/longs and I want to include a label that has all of the grouped column data.
# Make sample dataframe
long <- c(147.5, 147.5, 147.5, 147, 147)
lat <- c(-36.5, -36.5, -36.5, -36, -36)
label <- c(1, 1, 2, 1, 2)
markers <- data.frame(lat,long,label)
# Combine labels based on lat long
markers <- markers %>%
group_by(lat, long) %>%
summarize(concat_label = toString(label))
# Markers with all of the labels
leaflet() %>%
addTiles() %>%
addMarkers(lng=markers$long, lat= markers$lat,
popup= markers$concat_label
)
Is there a version of toString that uses a line break instead of a comma? I tried to use paste and paste0 but wasn't able to get it to work.
", detail1, detail2, detail3)`. – dshkol Sep 26 '17 at 17:21