Skip to main content

Module dataframe

Module dataframe 

Source
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:

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 DataFrame key column.
shape 🔒
DataFrameShape: the owned, GC-rooted return shape of the data.frame split verbs.

Structs§

BuiltDataFrame
An owned, GC-rooted data.frame built on the Rust side.
DataFrame
A cheap Copy view over a validated R data.frame.

Enums§

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

Constants§

CORRUPT_GROUPS_HINT 🔒
The fix that the corrupt-groups errors (DataFrameError::GroupsNotDataFrame, DataFrameError::MissingGroupRows, DataFrameError::BadGroupRows) append to their message.
STALE_GROUPS_HINT 🔒
The cause and the fix that the stale-.rows errors (DataFrameError::GroupIndexOutOfRange, DataFrameError::GroupRowUncovered, DataFrameError::GroupRowDuplicated) append to their message.

Traits§

ColumnSource 👻
Internal engine that turns a value into a data.frame-shaped List.
ColumnarFrame
Rust rows ↔ the pure-Rust columnar companion generated by #[derive(DataFrameRow)].
DataFrameRowConvert 👻
Row → DataFrame conversion glue emitted by #[derive(DataFrameRow)] on the row type.
DataFrameRowSplit 👻
Row → split-representation glue emitted by #[derive(DataFrameRow)] on enum row types.
FromDataFrame
R data.frame → Rust data. The data-frame analogue of TryFromSexp.
IntoDataFrame
Rust data → R data.frame. The data-frame analogue of IntoR.
IntoDataFrameSplit
Enum rows → variant-partitioned R data.frames. The split-representation sibling of IntoDataFrame.

Functions§

col_name 🔒 ⚠
Read the i-th column name from a STRSXP names vector.
column_named 🔒 ⚠
The first column of the data.frame list frame named name.
copy_frame_attrs 🔒 ⚠
Copy the frame attributes of from onto the new frame to.
extract_nrow 🔒
Extract nrow from R’s row.names attribute.
grouping_columns_kept 🔒 ⚠
Whether every grouping variable of the grouped frame from (the columns its groups attribute names, .rows aside) is a column of to that is the same SEXP as in from. false when groups is not a data frame.
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.
select_column_rows 🔒 ⚠
Row-subset one data.frame column at the 0-based rows idx (see DataFrame::select_rows for the per-kind rules). Returns it protected.
select_frame_rows 🔒 ⚠
The body of DataFrame::select_rows: row-subset the data.frame VECSXP frame at the 0-based rows idx. Shared with packed data.frame columns.
ungroup_frame 🔒 ⚠
Remove dplyr’s grouping from the frame to: its groups attribute and the grouped_df / rowwise_df entries of its class.
validate_equal_lengths 🔒
Validate that all columns in a NamedList have equal length, returning the common length.