These are substitutes for as.matrix() and as.data.frame() that leave a sparse matrix as-is.

maybe_matrix(x)

maybe_data_frame(x)

Arguments

x

A data frame, matrix, or sparse matrix.

Value

A data frame, matrix, or sparse matrix.