matrix_to_triplets: Conversion from matrix to coordinate/triplet format

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

View source: R/CMF.R

Description

The CMF code requires inputs to be speficied in a specific sparse format. This function converts regular R matrices into that format.

Usage

1

Arguments

orig

A matrix of class matrix

Details

The element X[i,j] on the i:th row and j:t column is represented as a triple (i,j,X[i,k]). The input for CMF is then a matrix where each row specifies one element, and hence the representation is of size Nx3, where N is the total number of observed entries.

In the original input matrix the missing entries should be marked as NA. In the output they will be completely omitted.

Even though this format reminds the representation often used for representing sparse matrices, it is important to notice that observed zeroes are retained in the representation. The elements missing from this representation are considered unknown, not zero.

Value

The input matrix in triplet/coordinate format.

Author(s)

Arto Klami and Lauri V<c3><a4>re

See Also

triplets_to_matrix

Examples

1
2
3
x <- matrix(c(1,2,NA,NA,5,6),nrow=3)
triplet <- matrix_to_triplets(x)
print(triplet)

CMF documentation built on May 20, 2017, 3:11 a.m.

Search within the CMF package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.