View source: R/advanced_R_studies.R
Takes in a dataframe, and returns the same dataframe with a label column formatted for plotly graphs.
Example:
routes <- c4aRs::plotlyLabel(routes, c("Type", "Name"), c("type", "name"), titleCol = "origin")
plot_ly(data = routes, type = 'scatter', x = ~lat, text = ~label)
1 | plotlyLabel(df, textNames, colNames, titleCol = NULL, title = NULL)
|
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. |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.