Macro extendr_api::prelude::r
source ยท macro_rules! r { ($e: expr) => { ... }; }
Expand description
Convert a rust expression to an R object.
Shorthand for Robj::from(x)
.
Example:
use extendr_api::prelude::*;
test! {
let fred = r!(1);
assert_eq!(fred, Robj::from(1));
let int_array = r!([1, 2, 3]);
assert_eq!(int_array.len(), 3);
let numeric_array = r!([1., 2., 3.]);
assert_eq!(numeric_array.len(), 3);
let logical_array = r!([true, false, true]);
assert_eq!(logical_array.len(), 3);
let numeric_array_with_na = r!([Some(1.), None, Some(3.)]);
assert_eq!(numeric_array_with_na.len(), 3);
}