Learn R Programming

nexus (version 0.3.0)

replace_zero: Zero-Replacement

Description

Multiplicative replacement of zeros.

Usage

# S4 method for CompositionMatrix
replace_zero(x, value, delta = 2/3)

Value

An CompositionMatrix object, where all zero values have been replaced.

Arguments

x

A CompositionMatrix object.

value

A numeric vector giving the detection limits of each part (in \((0,1)\)).

delta

A numeric vector specifying the fraction of the detection limit to be used in replacement.

Author

N. Frerebeau

References

Aitchison, J. (1986). The Statistical Analysis of Compositional Data. London: Chapman and Hall.

Martín-Fernández, J. A., Barceló-Vidal, C. & Pawlowsky-Glahn, V. (2003). Dealing with Zeros and Missing Values in Compositional Data Sets Using Nonparametric Imputation. Mathematical Geology, 35(3): 253-278. tools:::Rd_expr_doi("10.1023/A:1023866030544").

See Also

Other imputation methods: missing, replace_NA()

Examples

Run this code
## Data from Martín-Fernández et al. 2003
X <- data.frame(
  X1 = c(0.0000, 0.1304, 0.1963),
  X2 = c(0.1250, 0.3151, NA),
  X3 = c(0.1237, NA, NA),
  X4 = c(0.7253, 0.2002, 0.0819),
  X5 = c(0.0260, 0.3543, 0.0114)
)

## Coerce to a compositional matrix
Y <- as_composition(X)

## Replace zeros
Z <- replace_zero(Y, value = 0.02, delta = 2/3)
Z

Run the code above in your browser using DataLab