View source: R/dw_create_choropleth_map.R
dw_create_choropleth_map | R Documentation |
experimental Creates and returns a new Datawrapper Chroropleth map object. This function starts the map-making process
dw_create_choropleth_map(
basemap_id,
basemap_value,
values_col,
keys_col,
api_key = "environment",
title = NULL,
tooltip = list(title, body, fields = c()),
folderId = NULL
)
basemap_id |
Required. Can be retrieved by looking at |
basemap_value |
Required. Can be retrieved by looking at |
keys_col |
Required. Which column contains the keys for the map (as specified in |
api_key |
Required. A Datawrapper-API-key as character string. Defaults to "environment" - tries to automatically retrieve the key that's stored in the .Reviron-file by |
title |
Optional. Will set a map's title on creation. |
tooltip |
Optional. Specify a list including these vectors: |
folderId |
Optional. Creates chart in specified folder. |
value_col |
Required. Which column contains the values to be plotted on the map? |
It prints the new chart's id and returns a S3-structure of type dw_chart with the elements from the Datawrapper-API, the same as in dw_retrieve_chart_metadata
. After creating the chart you can populate and update it with dw_data_to_metadata
If not specified, the new chart will by default be created without a title.
Benedict Witzenberger
## Simple example:
## Not run:
dw_create_choropleth_map(
basemap_id = "world-2019",
basemap_value = "DW_STATE_CODE",
value_cols = "percentage",
key_cols = "iso_codes"
)
## End(Not run)
## Include a tooltip:
## Not run:
dw_create_choropleth_map(
basemap_id = "world-2019",
basemap_value = "DW_STATE_CODE",
value_cols = "percentage",
key_cols = "iso_codes",
tooltip = list(
title = "{{ State_Name }}",
body = "In {{ State_Name }} the value is {{percentage}} percent.",
fields = c("State_Name", "percentage")
))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.