Skip to main content

DataFrameRow

Derive Macro DataFrameRow 

Source
#[derive(DataFrameRow)]
{
    // Attributes available to this derive:
    #[dataframe]
}
Expand description

Derive DataFrameRow: generates a companion *DataFrame type with collection fields, plus IntoR / TryFromSexp / IntoDataFrame impls for seamless R data.frame conversion.

§Example

#[derive(DataFrameRow)]
struct Measurement {
    time: f64,
    value: f64,
}

// Generates MeasurementDataFrame { time: Vec<f64>, value: Vec<f64> }
// plus conversion impls

§Struct-level attributes

  • #[dataframe(name = "CustomDf")] — custom name for the generated DataFrame type
  • #[dataframe(align)] — pad shorter columns with NA to match longest
  • #[dataframe(tag = "my_tag")] — attach a tag attribute to the data.frame
  • #[dataframe(conflicts = "string")] — resolve conflicting column types as strings

§Field-level attributes

  • #[dataframe(skip)] — omit this field from the DataFrame
  • #[dataframe(rename = "col")] — custom column name
  • #[dataframe(as_list)] — keep collection as single list column (no expansion)
  • #[dataframe(expand)] / #[dataframe(unnest)] — expand collection into suffixed columns
  • #[dataframe(width = N)] — pin expansion width (shorter rows get NA)