EVOLUTION-MANAGER
Edit File: sparseVector.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Sparse Vector Construction from Nonzero Entries</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for sparseVector {Matrix}"><tr><td>sparseVector {Matrix}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Sparse Vector Construction from Nonzero Entries</h2> <h3>Description</h3> <p>User friendly construction of sparse vectors, i.e., objects inheriting from <code><a href="../../base/html/class.html">class</a></code> <code><a href="sparseVector-class.html">sparseVector</a></code>, from indices and values of its non-zero entries. </p> <h3>Usage</h3> <pre> sparseVector(x, i, length) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>vector of the non zero entries; may be missing in which case a <code>"nsparseVector"</code> will be returned.</p> </td></tr> <tr valign="top"><td><code>i</code></td> <td> <p>integer vector (of the same length as <code>x</code>) specifying the indices of the non-zero (or non-<code>TRUE</code>) entries of the sparse vector.</p> </td></tr> <tr valign="top"><td><code>length</code></td> <td> <p>length of the sparse vector.</p> </td></tr> </table> <h3>Details</h3> <p>zero entries in <code>x</code> are dropped automatically, analogously as <code><a href="drop0.html">drop0</a>()</code> acts on sparse matrices. </p> <h3>Value</h3> <p>a sparse vector, i.e., inheriting from <code><a href="../../base/html/class.html">class</a></code> <code><a href="sparseVector-class.html">sparseVector</a></code>. </p> <h3>Author(s)</h3> <p>Martin Maechler</p> <h3>See Also</h3> <p><code><a href="sparseMatrix.html">sparseMatrix</a>()</code> constructor for sparse matrices; the class <code><a href="sparseVector-class.html">sparseVector</a></code>. </p> <h3>Examples</h3> <pre> str(sv <- sparseVector(x = 1:10, i = sample(999, 10), length=1000)) sx <- c(0,0,3, 3.2, 0,0,0,-3:1,0,0,2,0,0,5,0,0) ss <- as(sx, "sparseVector") stopifnot(identical(ss, sparseVector(x = c(2, -1, -2, 3, 1, -3, 5, 3.2), i = c(15L, 10:9, 3L,12L,8L,18L, 4L), length = 20L))) (ns <- sparseVector(i= c(7, 3, 2), length = 10)) stopifnot(identical(ns, new("nsparseVector", length = 10, i = c(2, 3, 7)))) </pre> <hr /><div style="text-align: center;">[Package <em>Matrix</em> version 1.2-17 <a href="00Index.html">Index</a>]</div> </body></html>