Skip to main content

Packages

How to write packages with Vapour.

1. Create an R package

Create an R package as you normally would.

usethis::create_package("vapour.pkg")

2. Setup vapour

First, create a new directory to host the Vapour code.

mkdir vp

3. Inst

Second, create the inst directory, this is where Vapour will output a file containing your custom types.

mkdir inst

4. Write

Write some vapour code in the created vp directory.

#' Add one
#'
#' @param x An integer
#'
#' @export
func addOne(x: int): int {
stopifnot(!missing(x))
return x + 1
}
info

In Vapour the order of the files matter, do not use a variable declared in b.vp in a.vp.

5. Transpile

Transpile the code to R.

vapour -indir=vp

And you're done! You can now document, check, and install your package.

devtools::document()
devtools::check()
devtools::install()
info

Vapour does not read or parse roxygen2 @import or @importFrom, it is thus necessary to use the namespace :: when calling functions from other packages.