rgr (version 1.1.15)

ltdl.fix.df: Replace Negative Values Representing Less Than Detects in a Data Frame

Description

Function to process a matrix or data frame to replace negative values representing less than detects (<value) with positive half that value. This permits processing of these effectively categorical data as real numbers and their display on logarithmically scaled axes. Some software packages replace blank fields that should be interpreted as NAs, i.e. no information, with zeros, the facility is provided to replace any zero values with NAs. In other instances data files have been built using an integer code, e.g., -9999, to indicate 'no data', i.e. the equivalent of NAs. The facility is provided to replace any so coded values with NAs. If required, all <values and may be replaced with NAs, e.g. when estimating analytical precision with anova1 using only duplicate analyses with >DL values. Any factor variables in the input matrix or data frame are passed to the output matrix or data frame.

If a single vector is to be processed, use ltdl.fix

A report of the changes made is displayed on the current device.

Usage

ltdl.fix.df(x, negs2na = FALSE, zero2na = FALSE, coded = NA)

Arguments

x

name of the matrix or data frame to be processed.

negs2na

to replace any -ve values with NAs, set negs2na = TRUE.

zero2na

to replace any zero values with NAs, set zero2na = TRUE.

coded

to replace any numeric coded values, e.g., -9999 with NAs, set coded = -9999.

Value

A matrix or data frame identical to that input but where any negative values have been replaced by half their positive values, or NAs, and optionally any zero values or numeric coded values have been replaced by NAs.

References

Helsel, D.R., 2005. Nondetects and Data Analysis: Statistics for Censored Data. John Wiley & Sons, Ltd., 250 p.

Hron, K., Templ, M. and Filzmoser, P., 2010. Imputation of missing values for compositional data using classical and robust methods. Computational Statistics and Data Analysis, 54(12):3095-3107. 3107.

Templ, M., Hron, K. and Filzmoser, P., 2010. robCompositions: An R-package for Robust Statistical Analysis of Composition data. In: Compositional Data Analysis: Theory and Applications, V. Pawowsky and A. Buccianti (Eds.), Chapter 25, pp. 342-355. John Wiley & Sons, Ltd.

Martin-Fernadez, J.A., Hron, K., Templ, M., Filzmoser, P. and Palarea-Albaladejo, J., 2012. Model-based replacement of rounded zeros in compositional data: classical and robust approaches. Computational Statistics and Data Analysis, 56(9):2688-2704.

Palarea-Albaladejo, J. and Martin-Fernandez, J.A., 2013. Values below detection limit in compositional chemical data. Analytica Chemica Acta, 764:32-43.

See Also

ltdl.fix

Examples

Run this code
# NOT RUN {
## Replace any missing data coded as -9999 with NAs and any remaining
## negative values representing less than detects with Abs(value)/2
data(fix.test)
fix.test
fix.test.fixed <- ltdl.fix.df(fix.test, coded = -9999)
fix.test.fixed

## As above, and replace any zero values with NAs
fix.test.fixed <- ltdl.fix.df(fix.test, coded = -9999, zero2na = TRUE)
fix.test.fixed

## As above, but replace any negative values with NAs
fix.test.fixed <- ltdl.fix.df(fix.test, negs2na = TRUE, coded = -9999, zero2na = TRUE)
fix.test.fixed

## Clean-up
rm(fix.test.fixed)
# }

Run the code above in your browser using DataLab