test_hz_logic: Test Horizon Logic

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Simple tests for horizon logic, based on a simple data.frame of ordered horizons.

Usage

1
test_hz_logic(i, topcol, bottomcol, strict = FALSE)

Arguments

i

a data.frame associated with a single soil profile, ordered by depth

topcol

character, giving the name of the column in i that describes horizon top depth

bottomcol

character, giving the name of the column in i that describes horizon bottom depth

strict

logical, should continuity tests be performed– i.e. for non-contiguous horizon boundaries

Details

By default, this function tests for NA and overlapping horizons. If any either are encountered, FALSE is returned.

Value

logical: TRUE –> pass, FALSE –> fail

Author(s)

D.E. Beaudette

References

http://casoilresource.lawr.ucdavis.edu/

See Also

depths<-

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
## simple example: just one profile
data(sp1)
depths(sp1) <- id ~ top + bottom
s <- horizons(sp1[1, ])

## check
# fails due to missing hz boundary
s$bottom[6] <- NA # missing horizon boundary, common on bottom-most hz
test_hz_logic(s, 'top', 'bottom', strict=FALSE)

# fails due to inconsistent hz boundary
s$bottom[3] <- 30 # inconsistent hz boundary
test_hz_logic(s, 'top', 'bottom', strict=TRUE)


## filtering bad data 
## Not run: 
# missing bottom horizons
x$hzn_bot[!is.na(x$hzn_top) & is.na(x$hzn_bot)] <- x$hzn_top[!is.na(x$hzn_top) & is.na(x$hzn_bot)]

# remove O horizons where top > bottom
bad.O.hz.idx <- which(x$hzn_top > x$hzn_bot)
if(length(bad.O.hz.idx) > 0)
	x <- x[-bad.O.hz.idx, ]

## End(Not run)

## checking for bad data: do this before promoting to SoilProfileCollection object
library(plyr)
data(sp1)

# horizon logic can be tested via data.frame, at 2 levels of scrutiny:
ddply(sp1, 'id', test_hz_logic, topcol='top', bottomcol='bottom', strict=FALSE)
ddply(sp1, 'id', test_hz_logic, topcol='top', bottomcol='bottom', strict=TRUE)

aqp documentation built on May 2, 2019, 4:51 p.m.