popleaf {berryFunctions}R Documentation

create leaflet popup box info

Description

combine data.frame columns into a leaflet popup-box compatible format

Usage

popleaf(
  df,
  sel = colnames(df),
  truncate = NULL,
  tstring = "[...]",
  exclude_geometry = TRUE,
  na.rm = FALSE
)

Arguments

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

Value

Vector with character strings

Author(s)

Berry Boessenkool, berry-b@gmx.de, Apr 2017

See Also

paste

Examples

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="--")


[Package berryFunctions version 1.20.1 Index]