ms_to_df {matrixset}R Documentation

Convert matrixset to data frame

Description

Converts a matrixset to a data.frame (a tibble, more specifically), in a long format.

When as_list is TRUE, each matrix is converted separately. Row/column annotation is included if requested.

Usage

ms_to_df(
  .ms,
  add_row_info = TRUE,
  add_column_info = TRUE,
  as_list = FALSE,
  .matrix = NULL
)

Arguments

.ms

matrixset object to convert to data.frame

add_row_info

logical, to include row annotation or not

add_column_info

logical, to include column annotation or not

as_list

logical. By default (FALSE), a single tibble is returned with matrices as columns. When TRUE, the list structure, an element by converted matrix, is kept.

.matrix

matrix indices of which matrix to include in the conversion. The default, NULL, means all the matrices are used.

If not NULL, index is numeric or character vectors.

Numeric values are coerced to integer as by as.integer() (and hence truncated towards zero).

Character vectors will be matched to the matrix names of the object.

Can also be logical vectors, indicating elements/slices to replace. Such vectors are NOT recycled, which is an important difference with usual matrix replacement. It means that the logical vector must match the number of matrices in length.

Can also be negative integers, indicating elements/slices to leave out of the replacement.

Value

A tibble, or if as_list is TRUE, A list of data frames, an element per converted matrix

Examples

# includes both annotation
ms_to_df(student_results)

# includes only row annotation
ms_to_df(student_results, add_column_info = FALSE)


[Package matrixset version 0.3.0 Index]