Last data update: 2014.03.03

R: Render Dockerized R Markdown Documents
drenderR Documentation

Render Dockerized R Markdown Documents

Description

Render dockerized R Markdown documents using Docker containers. Rabix tools/workflows will be ran if there is a Rabixfile generated by lift under the same directory.

Usage

drender(input = NULL, tag = NULL, build_args = NULL,
  container_name = NULL, reset = TRUE, ...)

Arguments

input

Input file to render in Docker container.

tag

Docker image name to build, sent as docker argument -t. If not specified, it will use the same name as the input file.

build_args

A character string specifying additional docker build arguments. For example, --pull=true -m="1024m" --memory-swap="-1".

container_name

Docker container name to run. If not specified, we will generate and use a random name.

reset

Should we cleanup the Docker container and Docker image after getting the rendered result?

...

Additional arguments passed to render.

Details

Before using drender(), run lift on the document first to generate Dockerfile. See vignette('liftr-intro') for details about the extended YAML front-matter metadata format and system requirements for rendering dockerized R Markdown documents.

Value

Rendered file is written to the same directory of the input file. A character vector with the image name and container name will be returned. You will be able to manage them with docker commands later if reset = FALSE.

Examples

# 1. Dockerized R Markdown document
# Docker is required to run the example,
# so make sure we can use `docker` in shell.
dir_docker = paste0(tempdir(), '/drender_docker/')
dir.create(dir_docker)
file.copy(system.file("docker.Rmd", package = "liftr"), dir_docker)
docker_input = paste0(dir_docker, "docker.Rmd")
lift(docker_input)
## Not run: 
drender(docker_input)
# view rendered document
browseURL(paste0(dir_docker, "docker.html"))
## End(Not run)

# 2. Dockerized R Markdown document with Rabix options
# Docker and Rabix are required to run the example,
# so make sure we can use `docker` and `rabix` in shell.
dir_rabix  = paste0(tempdir(), '/drender_rabix/')
dir.create(dir_rabix)
file.copy(system.file("rabix.Rmd", package = "liftr"), dir_rabix)
rabix_input = paste0(dir_rabix, "rabix.Rmd")
lift(rabix_input)
## Not run: 
drender(rabix_input)
# view rendered document
browseURL(paste0(dir_rabix, "rabix.html"))
## End(Not run)

Results