sparsify: Sparsify: shoots a percentage of zero's in non-zero elements...

Description Usage Arguments Value Examples

View source: R/makeData.R

Description

At random set a percentage the non-zero elements of columns of a matrix to zero. This can be used to create a zero structure for the component weights/loadings from which to simulate data.

Usage

1
sparsify(comdis, sparsity)

Arguments

comdis

A data matrix of class matrix, with a common or distinctive structure. (i.e. zero and ones in pre specified locations)

sparsity

The percentage of non-zero elements in the columns of comdis that should be set to zero. This is a value between 0 and 1

Value

A matrix with a percentage of the non-zero elements in comdis set to zero

Examples

1
2
comdis <- matrix(1, 40, 3) 
sparsify(comdis, 0.7) #set 70% of the non-zero elements in comdis to zero

trbKnl/sparseWeightBasedPCA documentation built on July 22, 2020, 10:29 p.m.