Requirements
R blocks are only supported when running Mage using Docker.
Add R block to pipeline
- Create a new pipeline or open an existing pipeline.
- Add a data loader, transformer, or data exporter block.
- Select
R.
Example pipeline
- Data loader
- Transformer
- Data exporter
Install R packages
Add the following at the start of your code in your R block: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 viaglobal_vars vector, like global_vars['execution_date'].
Example code: