zeroreplace {compositions} | R Documentation |

## Zero-replacement routine

### Description

A function to automatically replace rounded zeroes/BDLs in a composition.

### Usage

```
zeroreplace(x,d=NULL,a=2/3)
```

### Arguments

`x` |
composition or dataset of compositions |

`d` |
vector containing the detection limits of each part |

`a` |
fraction of the detection limit to be used in replacement |

### Details

If `d`

is given, zeroes from each column of `x`

are replaced by the
corresponding detection limit contained there, scaled
down by the value of `a`

(usually a scalar, although if
it is a vector it will be recycled with a warning). The variable `d`

should
be a vector of length equal to `ncol(x)`

or a matrix of the same shape as `x`

.

If `d=NULL`

, then the detection limit is extracted from the data set,
if it is available there (i.e., if there are negative numbers). If no negative
number is present in the data set, and no value is given for `d`

, the
result will be equal to `x`

. See `compositions.missings`

for more
details on the missing policy.

### Value

an object of the same class as `x`

, where all WZERO values have been replaced.
Output contains a further attribute (named `Losts`

),
with a logical array of the same dimensions as `x`

,
showing which elements were replaced (TRUE) and which were
kept unchanged (FALSE).

### References

Aitchison, J. (1986) *The Statistical Analysis of Compositional
Data* Monographs on Statistics and Applied Probability. Chapman &
Hall Ltd., London (UK). 416p.

Mart\'in-Fern\'andez, J.A.; Barcel\'o-Vidal, C. and Pawlowsky-Glahn, V. (2003)
Dealing With Zeros and Missing Values in Compositional Data Sets
Using Nonparametric Imputation. *Mathematical Geology*, 35 , 253-278

https://ima.udg.edu/Activitats/CoDaWork03/

https://ima.udg.edu/Activitats/CoDaWork05/

### See Also

`compositions.missings`

,`getDetectionlimit`

### Examples

```
data(SimulatedAmounts)
x <- acomp(sa.lognormals)
xnew <- simulateMissings(x,dl=0.05,knownlimit=FALSE)
xnew
xrep <- zeroreplace(xnew,0.05)
xrep
```

*compositions*version 2.0-8 Index]