ltdl.fix.df {rgr} | R Documentation |
Function to process a matrix or dataframe 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. In addition, some software packages replace blank fields that should be interpreted as NA
s, i.e. no information, with zeros. The facility is provided to replace any zero values with NA
s. In other instances data files have been built using an integer code, e.g., -9999, to indicate 'no data', i.e. the equivalent of NA
s. The facility is provided to replace any so coded values with NA
s. 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.
ltdl.fix.df(x, zero2na = FALSE, coded = NA)
x |
name of the matrix or dataframe to be processed. |
zero2na |
to replace any zero values with NA s, set zero2na = TRUE . |
coded |
to replace any numeric coded values, e.g., -9999 with NA s, set coded = -9999 . |
A matrix or dataframe identical to that input but where any negative values have been replaced by half their positive values, and optionally any zero values or numeric coded values have been replaced by NA
s.
Great care needs to be taken when processing data where a large proportion of the data are less than detects (<
value). In such cases parametric statistics have limited value, and can be missleading. Records should be kept of variables containing <
values, and the fixed replacement values changed in tables for reports to the appropriate <
values. Thus, in tables of percentiles the <
value should replace the fixed value computed from absolute(-value)/2. Various rules have been proposed as to how many less than detects treated in this way can be tolerated before means, variances, etc. become biassed and of little value. Less than 5% in a large data set is usually tolerable, with greater than 10% concern increases, and with greater than 20% alternate procedures for processing the data should be sought.
Robert G. Garrett and David Lorenz
## 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