Learn R Programming

spam (version 0.20-3)

triplet: Transform a spam format to triplets

Description

Returns a list containing the indices and elements of a spam object.

Usage

triplet(x, tri=FALSE)

Arguments

x
sparse matrix of class spam or a matrix.
tri
Boolean indicating whether to create individual row and column indices vectors.

Value

  • A list with elements
  • indicesa by two matrix containing the indices if tri=FALSE.
  • i,jvectors containing the row and column indices if tri=TRUE.
  • valuesa vector containing the matrix elements

Details

The elements are row (column) first if x is a spam object (matrix).

See Also

spam.list for the inverse operation and foreign for other transformations.

Examples

Run this code
x <- diag.spam(1:4)
x[2,3] <- 5
triplet(x)
all.equal( spam(triplet(x, tri=TRUE)), x)

Run the code above in your browser using DataLab