View source: R/unsplitAsDataFrame.R
| unsplitAsDataFrame | R Documentation |
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.
unsplitAsDataFrame(
x,
row.names = TRUE,
column.names = TRUE,
row.field = "row",
column.field = "column",
value.field = "value"
)
x |
A BumpyMatrix object. |
row.names, column.names |
Logical scalar indicating whether the row or column names of |
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. |
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.
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).
Aaron Lun
splitAsBumpyMatrix, to do the split in the first place.
mat <- splitAsBumpyMatrix(runif(1000),
row=sample(LETTERS, 1000, replace=TRUE),
column=sample(10, 1000, replace=TRUE)
)
unsplitAsDataFrame(mat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.