Skip to main content

Requirements

R blocks are only supported when running Mage using Docker.

Add R block to pipeline

  1. Create a new pipeline or open an existing pipeline.
  2. Add a data loader, transformer, or data exporter block.
  3. Select R.

Example pipeline

  1. Data loader
  2. Transformer
  3. Data exporter

Install R packages

Add the following at the start of your code in your R block:
Or
Note When you run the R block for the 1st time, the package will be installed. The 2nd time you run the R block, the package won’t need to be installed again.

What is pacman?

pacman is an R package management tool. You can use p_library() to view all the available packages. Here is the documentation for pacman where you can find more useful methods: https://www.rdocumentation.org/packages/pacman/versions/0.5.1

Runtime variables

Runtime variables can be accessed via global_vars vector, like global_vars['execution_date']. Example code: