R and Rust¶
R¶
The R package lives in r/ of the repository and calls the same Rust core through
extendr. Its reference pages are at
neemiasbsilva.github.io/popfidelity/r.
remotes::install_github("neemiasbsilva/popfidelity", subdir = "r")
library(popfidelity)
survey <- read_cells(example_path("toy", "survey_cells.csv"))
Cells are popfidelity_cells objects built with cells_from_matrix(),
cells_from_long() or read_cells(); scored tables are tibbles.
Rust¶
The core crate, popfidelity in crates/popfidelity, has no dependencies and no
unsafe code; cargo add popfidelity adds it from crates.io. Its documentation is at
neemiasbsilva.github.io/popfidelity/rust.
use popfidelity::{Panel, Variant, evaluate};
let survey = Panel::new(vec![0.2, 0.8, 0.4, 0.6, 0.6, 0.4, 0.8, 0.2], 4, 2)?;
let model = Panel::new(vec![0.0, 1.0, 0.2, 0.8, 0.4, 0.6, 0.6, 0.4], 4, 2)?;
let (_, scores) = evaluate(&survey, &model, None, &Variant::default())?;