Expand description
R data.frame views, rooted Rust-built handles, and conversion traits.
DataFrame is a cheap Copy view over a validated data.frame SEXP;
BuiltDataFrame is the owned, GC-rooted handle returned by every
Rust-side constructor. Together they serve 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 new-frame producers return an owned, GC-rootedBuiltDataFrame(#1247), so constructor → edit chains stay rooted at every link.
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 (returns an owned, GC-rooted `BuiltDataFrame` that `Deref`s to `DataFrame`)
let df = rows.into_dataframe()?; // sequential
let df = rows.into_dataframe_par()?; // parallel (feature = "rayon")
// R → Rust
let rows: Vec<Row> = Vec::<Row>::from_dataframe(&df)?;DataFrame implements TryFromSexp and IntoR, so caller-rooted views slot
into #[miniextendr] argument and return conversion. BuiltDataFrame also
implements IntoR; return rooted Rust-side constructor results directly.
§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::GroupDeclaration;pub use group::GroupKey;pub use group::GroupedDataFrame;pub use group::RealKey;pub use group::group_rows;pub use shape::DataFrameShape;pub use shape::SplitResults;
Modules§
- group
- Group-level iteration over a
DataFramekey column. - shape 🔒
DataFrameShape: the owned, GC-rooted return shape of the data.frame split verbs.
Structs§
- Built
Data Frame - An owned, GC-rooted
data.framebuilt on the Rust side. - Data
Frame - A cheap
Copyview over a validated Rdata.frame.
Enums§
- Data
Frame Error - Error returned by any
DataFrameconstruction, read, or conversion path.
Constants§
- CORRUPT_
GROUPS_ 🔒HINT - The fix that the corrupt-
groupserrors (DataFrameError::GroupsNotDataFrame,DataFrameError::MissingGroupRows,DataFrameError::BadGroupRows) append to their message. - STALE_
GROUPS_ 🔒HINT - The cause and the fix that the stale-
.rowserrors (DataFrameError::GroupIndexOutOfRange,DataFrameError::GroupRowUncovered,DataFrameError::GroupRowDuplicated) append to their message.
Traits§
- Column
Source 👻 - Internal engine that turns a value into a
data.frame-shapedList. - Columnar
Frame - Rust rows ↔ the pure-Rust columnar companion generated by
#[derive(DataFrameRow)]. - Data
Frame 👻RowConvert - Row → DataFrame conversion glue emitted by
#[derive(DataFrameRow)]on the row type. - Data
Frame 👻RowSplit - Row → split-representation glue emitted by
#[derive(DataFrameRow)]on enum row types. - 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. - Into
Data Frame Split - Enum rows → variant-partitioned R
data.frames. The split-representation sibling ofIntoDataFrame.
Functions§
- col_
name 🔒 ⚠ - Read the i-th column name from a STRSXP names vector.
- column_
named 🔒 ⚠ - The first column of the data.frame list
framenamedname. - copy_
frame_ 🔒 ⚠attrs - Copy the frame attributes of
fromonto the new frameto. - extract_
nrow 🔒 - Extract
nrowfrom R’srow.namesattribute. - grouping_
columns_ 🔒 ⚠kept - Whether every grouping variable of the grouped frame
from(the columns itsgroupsattribute names,.rowsaside) is a column oftothat is the same SEXP as infrom.falsewhengroupsis not a data frame. - 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.
- select_
column_ 🔒 ⚠rows - Row-subset one data.frame column at the 0-based rows
idx(seeDataFrame::select_rowsfor the per-kind rules). Returns it protected. - select_
frame_ 🔒 ⚠rows - The body of
DataFrame::select_rows: row-subset the data.frame VECSXPframeat the 0-based rowsidx. Shared with packed data.frame columns. - ungroup_
frame 🔒 ⚠ - Remove dplyr’s grouping from the frame
to: itsgroupsattribute and thegrouped_df/rowwise_dfentries of its class. - validate_
equal_ 🔒lengths - Validate that all columns in a NamedList have equal length, returning the common length.