popleaf | R Documentation |
combine data.frame columns into a leaflet popup-box compatible format
popleaf(
df,
sel = colnames(df),
truncate = NULL,
tstring = "[...]",
exclude_geometry = TRUE,
na.rm = FALSE
)
df |
Data.frame |
sel |
Columns to be selected (Names or index or TRUE/FALSE vector). DEFAULT: colnames(df) |
truncate |
Numeric: number of characters beyond which to truncate columns. DEFAULT: NULL (no truncation) |
tstring |
Charstring to add at the end if truncated. DEFAULT: "[...]" |
exclude_geometry |
Remove column with the name "geometry" (as in sf objects) from the display? DEFAULT: TRUE |
na.rm |
Exclude NA entries from the display? DEFAULT: FALSE |
Vector with character strings
Berry Boessenkool, berry-b@gmx.de, Apr 2017
paste
dat <- data.frame(a=14:16, b=letters[14:16], c=LETTERS[14:16],
lat=c(52.58,53.45,52.4), lon=c(6.34,7.23,13.05))
popleaf(dat)
dat$display <- popleaf(dat, 1:4)
## Not run: # Excluded from CRAN checks
library(leaflet)
leaflet(dat) %>% addTiles() %>% addCircleMarkers(~lon, ~lat, popup=~display)
## End(Not run)
dat[1,1] <- "Very long string I'd rather have truncated"
popleaf(dat, 1:3)
popleaf(dat, 1:3, truncate=16)
popleaf(dat, 1:3, truncate=16, tstring="--")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.