Skip to main content

Module dataframe

Module dataframe 

Source
Expand description

The unified owned R data.frame type and its conversion traits.

DataFrame is the data-frame type: a single owned wrapper around a built data.frame SEXP that serves every direction —

The trait family mirrors the crate’s existing IntoR / TryFromSexp pair, specialised to the data-frame SEXP:

use miniextendr_api::dataframe::{DataFrame, IntoDataFrame, FromDataFrame};

// Rust → R
let df: DataFrame = rows.into_dataframe()?;          // sequential
let df: DataFrame = rows.into_dataframe_par()?;      // parallel (feature = "rayon")

// R → Rust
let rows: Vec<Row> = Vec::<Row>::from_dataframe(&df)?;

DataFrame implements both IntoR and TryFromSexp, so it slots into #[miniextendr] function codegen with no special-casing — return it directly or accept it as an argument.

§One error contract

Every conversion failure surfaces as DataFrameError. The serde column assembler’s internal RSerdeError is bridged via From<RSerdeError>; the parallel R→Rust reader reports through DataFrameError rather than a bare String.

Re-exports§

pub use group::GroupKey;
pub use group::GroupedDataFrame;
pub use group::group_rows;

Modules§

group
Group-level iteration over a DataFrame key column.

Structs§

DataFrame
An owned, validated R data.frame. The data-frame type.
NamedDataFrameListBuilder
Assemble a named list whose elements are DataFrames, without per-result OwnedProtect bookkeeping.

Enums§

DataFrameError
Error returned by any DataFrame construction, read, or conversion path.

Traits§

ColumnSource 👻
Internal engine that turns a value into a data.frame-shaped List.
DataFrameRowConvert 👻
Row → DataFrame conversion glue emitted by #[derive(DataFrameRow)] on the row type.
FromDataFrame
R data.frame → Rust data. The data-frame analogue of TryFromSexp.
IntoDataFrame
Rust data → R data.frame. The data-frame analogue of IntoR.

Functions§

col_name 🔒
Read the i-th column name from a STRSXP names vector.
copy_df_attrs 🔒
Copy class and row.names attributes from one data.frame SEXP to another.
extract_nrow 🔒
Extract nrow from R’s row.names attribute.
no_reader_error 🔒
Error returned by Vec::<Row>::from_dataframe when the row shape has no R→Rust reader.
nrow_from_first_column 🔒
Fall back: extract nrow from the length of the first column.
validate_equal_lengths 🔒
Validate that all columns in a NamedList have equal length, returning the common length.