Building a Content Delivery Pipeline for a Website in R

Embedding web components from R into
a content management system

Created by Gregor de Cillia, Alexander Kowarik and Bernhard Meindl
from the methodology unit of Statistics Austria

Abstract

Statistics Austria is currently working towards the release of a new website. An important part of it, namely graphs and tables, will be created using R

Content creators will create graphs and tables via a shiny app and transfer them to the content management system (CMS). The transfer uses a plumber REST API under the hood

Parts of the presentation

  1. Showcase the app and components
  2. Remarks about the data import
  3. Mechanism to transfer components from the app to the CMS

Components

The components that can be delivered by the pipeline are graphs and tables

Both the graphs and tables are interactive in the sense that they provide hover and/or click events

Graphs

Graphs are generated with highcharts.js and the corresponding R package highcharter

Tables

Tables are created using datatables.js which provides features like sorting, searching and more

Component Builder App

The component builder app is a shiny application which is hosted on RStudio Connect. It guides the content creator through the component generation process

  • Data can be imported from different sources
  • Components can be created and previewed. Sensible defaults make it possible do this with a few clicks
  • An export menu makes the component accessible for the CMS

Demo Video: App

Transfer: App to CMS

In order to make the graphs and tables available for the CMS, a REST API is used. The app exports the components to a database and the CMS imports the components

The API is built with plumber and hosted on RSConnect

Export: App to Database

When a user exports a graph or table, the app performs a /POST request against the component API

The component is submitted as a binary object in the request body and added to a BLOB field in the component database

The database also captures metadata about the component such as the author and a timestamp

The /GET method of the component API lists all components in a json format. A tabular representation is provided below
httr::GET("rsconnect.local/component-api")

Each row represents a graph, a table or both. Notice the NULL values in the last two rows

The columns Creator and Data Source reference the user and dataset behind a component

Most Valuable Packages

Frameworks

  • shiny defines the component builder app
  • The component API is generated with plumber

Front End

Back End

  • httr communicates with the plumber API and the STATcube API
  • Data import is performed with the STATcubeR package

Open Source Roadmap

Currently, the package STATcubeR is available on github. It will be released to CRAN when the STATcube REST API becomes available for external users

The internal packages STATgraph and STATtable, which create graphs and tables based on the STATcubeR data interface, might become open-source once the pipeline is fully integrated in the CMS workflow

Building a Content Delivery Pipeline for a Website in R

Thank you very much for your attention

Created by Gregor de Cillia, Alexander Kowarik and Bernhard Meindl
from the methodology unit of Statistics Austria
For more information, follow the link on the top right corner