rSpMatrix: Generate sparse matrix with at least one non-zero element by...

Description Usage Arguments Value Examples

View source: R/rSparseWeightMatrix.R

Description

Generate sparse matrix with at least one non-zero element by rows and by columns

Usage

1
rSpMatrix(nrow, ncol, sparse.coeff)

Arguments

nrow

An integer that is the number of rows.

ncol

An integer that is the number of columns.

sparse.coeff

A numeric in [0,1] that control the sparsity by rows (the proportion of non-zero entries among all matrix entries). Non-zero entries is define by nnz = sparse.coeff * nrow * ncol and need to be larger than nrow and ncol.

Value

A matrix of weights (each row sums to one).

Examples

1
M <- rSpMatrix(nrow=10L, ncol=7L, sparse.coeff=0.5)

pneuvial/c3co documentation built on May 25, 2019, 10:21 a.m.