odin_package: Create odin model in a package

Description Usage Arguments Details Examples

View source: R/odin_package.R

Description

Create an odin model within an existing package.

Usage

1
odin_package(path_package)

Arguments

path_package

Path to the package root (the directory that contains DESCRIPTION)

Details

I am resisting the urge to actually create the package here. There are better options than I can come up with; for example devtools::create, pkgkitten::kitten, mason::mason, or creating DESCRIPTION files using desc. What is required here is that your package:

Point this function at the package root (the directory containing DESCRIPTION and it will write out files src/odin.c and odin.R. These files will be overwritten without warning by running this again.

There are a few unresolved issues with this approach, notably activating "native symbol registration", and the interaction with packages such as Rcpp that automatically collate a list of symbols. The mechanism may change in a future version, though the interface (with source files in inst/odin will remain the same.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
path <- tempfile()
dir.create(path)

src <- system.file("examples/package", package = "odin", mustWork = TRUE)
file.copy(src, path, recursive = TRUE)
pkg <- file.path(path, "package")

# The package is minimal:
dir(pkg)

# But contains odin files in inst/odin
dir(file.path(pkg, "inst/odin"))

# Compile the odin code in the package
odin::odin_package(pkg)

# Which creates the rest of the package structure
dir(pkg)
dir(file.path(pkg, "R"))
dir(file.path(pkg, "src"))

richfitz/odin documentation built on July 21, 2020, 7:43 p.m.