The goal of DatawRappr is to provide a wrapper for Datawrapper’s API to connect data from R directly with Datawrapper’s charts capabilities. It uses the new API version 3.0.
datawrapper_auth()
dw_data_to_chart()
All functions (except datawrapper_auth()
) are preceded by dw_
:
dw_test_key()
dw_list_charts()
.dw_list_folders()
.dw_create_chart()
dw_copy_chart()
dw_data_to_chart()
dw_retrieve_chart_metadata()
) or edits metadata, description and visualization of an existing chart via dw_edit_chart()
dw_publish_chart()
dw_delete_chart()
dw_export_chart()
Right now this package is experimental and only available on Github:
# install.packages("devtools") # if not already installed on your system
devtools::install_github("munichrocker/DatawRappr")
Add the package to your environment by running:
library(DatawRappr)
To use the API you have to create an API key on Datawrapper.
Click on Dashboard - Settings and move down to the section that says API Access Tokens.
Click on Create new personal access token, enter a name and save the token:
Copy the API key in the clipboard and use
datawrapper_auth(api_key = "12345678")
to save the key to our system. If a key already exists, you may add the argument overwrite = TRUE
to datawrapper_auth()
.
To make sure, your key is working as expected, you can run
dw_test_key()
with no arguments. It will then use the saved key from the environment. If the key is correct, you will receive a response from the API with personal details about your account - a dw_user
-object that has no further use than to check your key.
Note: If you want to see your currently saved API key, you may use the helper function dw_get_api_key()
.
Congratulations, you’re good to go!
This package makes heavy use of the httr
-package, which on itself is a wrapper of the curl-package.
There is a API-documentation and a Getting Started guide with examples from Datawrapper.
A full Package-documentation can be found here.