XDataFrame-class {Cardinal} | R Documentation

## XDataFrame: DataFrame with eXtra metadata columns

### Description

An `XDataFrame` is an (indirect) extension of the `DataFrame` class as defined in the 'S4Vectors' package, modified to support eXtra "slot-columns" that behave differently from other columns. It is intended to facilitate `data.frame`-like classes that require specialized column access and behavior. The specialized slot-columns are stored as distinct slots, unlike regular columns.

### Usage

    XDataFrame(...)

### Arguments

`...` | Arguments passed to the `DataFrame()`.

### Details

For the most part, `XDataFrame` behaves identically to `DataFrame`, with the exception of certain methods being overwritten to account for the additional eXtra "slot-columns" not counted among those returned by `ncol(x)`. These additional columns should typically have their own getter and setter methods.

To implement a subclass of `XDataFrame`, one needs to implement two methods to allow the slot-columns to be printed by `show` and retained during coercion: (1) the subclass should implement an `as.list()` method that includes the slot columns in the resulting list by default and (2) the subclass should implement a `showNames()` method that returns the names of all the printable columns (including slot-columns) in the same order as they are returned by `as.list()`.

### Methods

`names(object)`:

  Return the column names, not including any slot-columns.

`length(object)`:

  Return the number of columns, not including any slot-columns.

`lapply(X, FUN, ..., slots = FALSE)`:

  Returns a list of the same length as `X`, where each element is the result of applying `FUN` to the corresponding element of `X`. This version includes an additional argument for whether the slot-columns should be included or not. This method should be overwritten by subclasses to ensure correct behavior.

`as.env(x, ...)`:

  Create an environment from `x` with a symbol for each column, including the slot-columns. This method should be overwritten by subclasses to ensure correct behavior.

### Author(s)

Kylie A. Bemis

### See Also

`DataFrame`, `MassDataFrame`, `PositionDataFrame`

### Examples

    ## Create an XDataFrame object
    XDataFrame(x=1:10, y=letters[1:10])

[Package Cardinal version 2.8.0 Index]