Giter Club home page Giter Club logo

rextendr's Introduction

Call Rust code from R rextendr logo

R build status CRAN status Lifecycle: stable

Installation

To install the package, run:

remotes::install_github("extendr/rextendr")

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.

Usage

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:

```{extendr}
rprintln!("Hello from Rust!");

let x = 5;
let y = 7;
let z = x*y;

z
```

would create the following output in the knitted document:

rprintln!("Hello from Rust!");

let x = 5;
let y = 7;
let z = x*y;

z
#> Hello from Rust!
#> [1] 35

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.

rextendr's People

Contributors

clauswilke avatar ilia-kosenkov avatar yutannihilation avatar malcolmbarrett avatar cgmossa avatar dasmoth avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.