logo
macro_rules! factor {
    ($($rest: tt)*) => { ... };
}
Expand description

Create a factor.

Example:

use extendr_api::prelude::*;
test! {
    let factor = factor!(vec!["abcd", "def", "fg", "fg"]);
    assert_eq!(factor.levels().unwrap().collect::<Vec<_>>(), vec!["abcd", "def", "fg"]);
    assert_eq!(factor.as_integer_vector().unwrap(), vec![1, 2, 3, 3]);
    assert_eq!(factor.as_str_iter().unwrap().collect::<Vec<_>>(), vec!["abcd", "def", "fg", "fg"]);
}

Panics on error.