Learn R Programming

nexus (version 0.3.0)

closure: Closure Operation

Description

Closes compositions to sum to 1.

Usage

closure(x, ...)

# S4 method for numeric closure(x, total = 1, na.rm = TRUE)

# S4 method for matrix closure(x, total = 1, na.rm = TRUE)

Value

A numeric vector or matrix (same as x).

Arguments

x

A numeric vector or matrix.

...

Currently not used.

total

A numeric vector specifying the total amount to which the compositions should be closed (defaults to 1).

na.rm

A logical scalar: should missing values be removed?

Author

N. Frerebeau

See Also

Other operations in the simplex: arithmetic, perturbation(), powering(), scalar()

Examples

Run this code
x <- as_composition(c(1, 2, 3))
y <- as_composition(c(1, 2, 1))

## Perturbation
perturbation(x, y)
x + y

## Powering
powering(y, 2)
y * 2

## Scalar product
scalar(x, y)

Run the code above in your browser using DataLab