unsplitAsDataFrame: Unsplit a BumpyMatrix

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/unsplitAsDataFrame.R

Description

Unsplit a BumpyMatrix into a DataFrame, adding back the row and column names as separate columns. This is equivalent to converting the BumpyMatrix into a “long” format.

Usage

1
2
3
4
5
6
7
8
unsplitAsDataFrame(
  x,
  row.names = TRUE,
  column.names = TRUE,
  row.field = "row",
  column.field = "column",
  value.field = "value"
)

Arguments

x

A BumpyMatrix object.

row.names, column.names

Logical scalar indicating whether the row or column names of x should be reported in the output.

row.field, column.field

String indicating the field in the output DataFrame to store the row or column names.

value.field

String specifying the field in the output DataFrame to store BumpyAtomicMatrix values.

Details

Denote the output of this function as y. Given a BumpyAtomicMatrix x, we would expect to be able to recover x by calling splitAsBumpyMatrix(y$value, y$row, y$column).

The row.field, column.field and value.field arguments can be used to alter the column names of the output DataFrame. This can be helpful to avoid, e.g., conflicts with columns of the same name in a BumpyDataFrameMatrix x.

If no row/column names are present in x (or row.names or column.names is FALSE), the row and column columns instead hold integer indices specifying the matrix row/column of each DataFrame row.

Value

A DataFrame object containing the data in x. This has additional row and column columns containing the row/column names for each DataFrame row.

If x is a BumpyAtomicMatrix, the output DataFrame contains a value column that holds unlist(x). Otherwise, if x is a BumpyDataFrameMatrix, the DataFrame contains the columns in unlist(x).

Author(s)

Aaron Lun

See Also

splitAsBumpyMatrix, to do the split in the first place.

Examples

1
2
3
4
5
6
mat <- splitAsBumpyMatrix(runif(1000), 
   row=sample(LETTERS, 1000, replace=TRUE),
   column=sample(10, 1000, replace=TRUE)
)

unsplitAsDataFrame(mat)

LTLA/BumpyMatrix documentation built on July 5, 2021, 2:21 a.m.