View source: R/advanced_R_studies.R
Takes in a dataframe, and returns the same dataframe with a label column formatted for leaflet maps.
Example:
leaf <- leafletLabel(routes, c("Type", "Name"), c("type", "name"), titleCol = "origin")
leaf <- leaflet(leaf)
leaf <- addMarkers(leaf, lng = ~long, lat = ~lat, popup = ~label)
1 | leafletLabel(df,textNames,colNames,titleCol=NULL,title=NULL,size=2,titleSize=4,digits=2)
|
df |
The dataframe you wish to label |
textNames |
The names of the text fields you want to display. Should correspond to colNames. |
colNames |
The names of the columns whose text you want to display. Should correspond to textNames. |
titleCol |
Optional. The name of the column that holds a title for your tooltips. |
title |
Optional. The name you wish to apply to all your tooltips. |
size |
Size of regular text, Default 2. |
titleSize |
Size of title text, Default 4. |
digits |
Number of digits to round numeric columns to, Default 2. |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.