xSM2DF: Function to create a data frame (with three columns) from a...

View source: R/xSM2DF.r

xSM2DFR Documentation

Function to create a data frame (with three columns) from a (sparse) matrix

Description

xSM2DF is supposed to create a data frame (with three columns) from a (sparse) matrix. Only nonzero/nonna entries from the matrix will be kept in the resulting data frame.

Usage

xSM2DF(data, verbose = TRUE)

Arguments

data

a matrix or an object of the dgCMatrix class (a sparse matrix)

verbose

logical to indicate whether the messages will be displayed in the screen. By default, it sets to TRUE for display

Value

a data frame containing three columns: 1st column for row names, 2nd for column names, and 3rd for numeric values

Note

none None

See Also

xSM2DF

Examples

# create a sparse matrix of 4 X 2
input.file <- rbind(c('R1','C1',1), c('R2','C1',1), c('R2','C2',1),
c('R3','C2',2), c('R4','C1',1))
data <- xSparseMatrix(input.file)
## Not run: 
# convert into a data frame
res_df <- xSM2DF(data)
res_df

## End(Not run)

hfang-bristol/XGR documentation built on Feb. 4, 2023, 7:05 a.m.