dw_create_choropleth_map: Creates a new Datawrapper Chroropleth Map

View source: R/dw_create_choropleth_map.R

dw_create_choropleth_mapR Documentation

Creates a new Datawrapper Chroropleth Map

Description

\lifecycle

experimental Creates and returns a new Datawrapper Chroropleth map object. This function starts the map-making process

Usage

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
)

Arguments

basemap_id

Required. Can be retrieved by looking at dw_basemaps.

basemap_value

Required. Can be retrieved by looking at dw_basemaps.

keys_col

Required. Which column contains the keys for the map (as specified in dw_basemaps)?

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 datawrapper_auth.

title

Optional. Will set a map's title on creation.

tooltip

Optional. Specify a list including these vectors: title, body, fields. Include all used variables in fields. Use " variable name " as placeholders in title and body.

folderId

Optional. Creates chart in specified folder.

value_col

Required. Which column contains the values to be plotted on the map?

Value

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

Note

If not specified, the new chart will by default be created without a title.

Author(s)

Benedict Witzenberger

Examples


## 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)


munichrocker/DatawRappr documentation built on March 20, 2024, 6:08 a.m.