Learn R Programming

IRanges (version 2.0.1)

DataFrame-utils: Common operations on DataFrame objects

Description

Common operations on DataFrame objects.

Arguments

Splitting and Combining

In the following code snippets, x is a DataFrame.
split(x, f, drop = FALSE): Splits x into a CompressedSplitDataFrameList, according to f, dropping elements corresponding to unrepresented levels if drop is TRUE.
rbind(...): Creates a new DataFrame by combining the rows of the DataFrame objects in .... Very similar to rbind.data.frame, except in the handling of row names. If all elements have row names, they are concatenated and made unique. Otherwise, the result does not have row names. Currently, factors are not handled well (their levels are dropped). This is not a high priority until there is an XFactor class.
cbind(...): Creates a new DataFrame by combining the columns of the DataFrame objects in .... Very similar to cbind.data.frame, except row names, if any, are dropped. Consider the DataFrame as an alternative that allows one to specify row names.
mstack(..., .index.var = "name"): Stacks the data frames passed as through ..., using .index.var as the index column name. See stack.

Aggregation

In the following code snippets, data is a DataFrame.
aggregate(x, data, FUN, ..., subset, na.action = na.omit): Aggregates the DataFrame data according to the formula x and the aggregating function FUN. See aggregate and its method for formula.

See Also

DataTable, Vector, and RangedData, which makes heavy use of this class.

Examples

Run this code
## split

sw <- DataFrame(swiss)
swsplit <- split(sw, sw[["Education"]])
  
## rbind

do.call(rbind, as.list(swsplit))

## cbind

cbind(DataFrame(score), DataFrame(counts))

Run the code above in your browser using DataLab