norm0: Norm 0

Description Usage Arguments Value Examples

View source: R/algebra.R

Description

Compute the number of non-zero values.

Usage

1
norm0(x, rev = FALSE, prop = FALSE)

Arguments

x

Numeric.

rev

If TRUE, returns the number of zeros in x.

prop

If TRUE, returns the proportion of (non-)zeros in x.

Value

By default, the number of non-zero values in x (\|x\|_0). If rev is set to TRUE, the number of zero in x. If prop is set to TRUE, i return the proportion instead of the absolute count.

Examples

1
2
3
4
x <- c(1, 2, 3, 0, 4)
norm0(x)
norm0(x, rev = TRUE)
norm0(x, prop = TRUE)

abichat/zazou documentation built on Sept. 8, 2021, 6:53 a.m.