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 —
- build (Rust → R):
IntoDataFrame::into_dataframe/into_dataframe_par(feature = "rayon"), - read (R → Rust):
DataFrame::column/FromDataFrame::from_dataframe, - edit (post-assembly):
DataFrame::rename/DataFrame::drop/DataFrame::select/ …
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§
Structs§
- Data
Frame - An owned, validated R
data.frame. The data-frame type. - Named
Data Frame List Builder - Assemble a named list whose elements are
DataFrames, without per-resultOwnedProtectbookkeeping.
Enums§
- Data
Frame Error - Error returned by any
DataFrameconstruction, read, or conversion path.
Traits§
- Column
Source 👻 - Internal engine that turns a value into a
data.frame-shapedList. - Data
Frame 👻RowConvert - Row → DataFrame conversion glue emitted by
#[derive(DataFrameRow)]on the row type. - From
Data Frame - R
data.frame→ Rust data. The data-frame analogue ofTryFromSexp. - Into
Data Frame - Rust data → R
data.frame. The data-frame analogue ofIntoR.
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
nrowfrom R’srow.namesattribute. - no_
reader_ 🔒error - Error returned by
Vec::<Row>::from_dataframewhen 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.