[][src]Crate extendr_api

extendr - A safe and user friendly R extension interface.

This library aims to provide an interface that will be familiar to first-time users of Rust or indeed any compiled language.

Anyone who knows the R library should be able to write R extensions.

See the Robj struct for much of the content of this crate. Robj provides a safe wrapper for the R object type.

This library is just being born, but goals are:

Implement common R functions such as c() and print()

Example:

This example is not tested
let v = c!(1, 2, 3);
let l = list!(a=1, b=2);
print!(v, l);

Provide a wrapper for r objects.

Example:

This example is not tested
let s = Robj::from("hello");
let i = Robj::from(1);
let r = Robj::from(1.0);

Provide iterator support for creation and consumption of r vectors.

Example:

This example is not tested
let res = (1..=100).iter().collect::<Robj>();
for x in res {
    print!(x);
}

Provide a procedural macro to adapt Rust functions to R

Example:

This example is not tested
#[extendr]
fn fred(a: i32) -> i32 {
    a + 1
}

In R:

This example is not tested

result <- .Call("fred", 1)

Macros

append_lang

Convert a list of tokens to an array of tuples.

args
c

Concatenation operator.

data_frame

Create a dataframe.

extendr_module

Define a module and export symbols to R Example:

lang

A macro for constructing R langage objects.

list

Create a list.

push_args

Convert a list of tokens to an array of tuples.

r

R object encapsulation operator.

read_table

Read a CSV file.

rep

Create a vector with repeating elements.

Structs

CallMethod
Character

Wrapper for creating character objects.

Lang

Wrapper for creating language objects.

List

Wrapper for creating list objects.

ListIter
R_CallMethodDef
StrIter
Symbol

Wrapper for creating symbols.

VecIter

Enums

Robj

Wrapper for an R S-expression pointer (SEXP).

Constants

FALSE
NULL
TRUE

Traits

AsTypedSlice
FromRobj

Functions

R_forceSymbols
R_registerRoutines
R_useDynamicSymbols
append
append_with_name
end_r

Close down the R interpreter. Note you won't be able to Restart it, so use with care or not at all.

make_lang
new_borrowed
new_owned
new_sys
register_call_methods
start_r
unwrap_or_throw

Throw an R error if a result is an error.

Type Definitions

AnyError

Generic dynamic error type.

DllInfo
SEXP

Attribute Macros

extendr

Generate bindings for a single function.