To install the package, run:
Note that this will install the package but does not guarantee that the package can do anything useful. You will also need to set up a working Rust toolchain. See the installation instructions for libR-sys for help. If you can successfully build libR-sys you’re good.
Basic use example:
library(rextendr)
# create a Rust function
rust_function("fn add(a:f64, b:f64) -> f64 { a + b }")
# call it from R
add(2.5, 4.7)
#> [1] 7.2
The package also enables a new chunk type for knitr, extendr
, which compiles and evaluates Rust code. For example, a code chunk such as this one:
would create the following output in the knitted document:
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.