sumComposition: Percentage Composition

View source: R/sumComposition.R

sumCompositionR Documentation

Percentage Composition

Description

Compute percentage or proportion of elements in a composition.

Usage

sumComposition(x, ..., Range = 100)

Arguments

x

any numeric vector, matrix, or data frame containing only numeric columns.

...

any additional vectors or matrices.

Range

the output range, generally 100 for percentages (the default) or 1 for proportions.

Details

Missing values are permitted in x or ... and result in missing values for the row in the output.

Value

A matrix with columns matching all of the data in x and ...{} with rows summing to Range.

Note

This function is designed to meet a very simple need in some applications like constructing data for Piper (Piper, 1944) or trilinear diagrams. For more in-depth manipulations of compositional data, the user is directed to the compositions or other similar package.

References

Piper, A.M., 1944, A graphical procedure in the geochemical interpretation of water analyses: Transactions of the American Geophysical Union, v. 25, p. 914-923.

Examples


# Create tiny dataset
TinyCations <- data.frame(Ca=c(32, 47, 28), Mg=c(10,12,15), Na=c(7, 5, 7))
sumComposition(TinyCations)

USGS-R/smwrBase documentation built on Oct. 18, 2022, 9:55 a.m.