21 Package structure
Objective
Understand the directory structure of extendr-based R packages.
The basic structure of an extendr-based R package is like so:
.
├── DESCRIPTION
├── NAMESPACE
├── R
├── configure
├── configure.win
├── man
├── src
└── tools
tools/,configure, andconfigure.winare used at package build and install time to ensure that Rust is avaialble.- primarily for
R CMD checkandCRANappeasement
- primarily for
Compiled Code
R packages that have compile code must store the source in src/. The src/ directory has the structure:
.
├── Makevars
├── Makevars.in
├── Makevars.win.in
└── rust
├── Cargo.lock
├── Cargo.toml
├── src
rust/is a library crate that is linked to by RMakevarsfiles builds the Rust library and links it to R
Rust libraries
Rust library crates have lib.rs instead of main.rs. There is no entrypoint that gets executed. Instead, we define functions, structs, enums, etc. that are used by the R package.