Learn R Programming

aqp (version 1.0)

test_hz_logic: Test Horizon Logic

Description

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

Usage

test_hz_logic(i, topcol, bottomcol, test.NA = TRUE, 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
test.NA
logicial, should tests for missing (NA) horizon top OR bottom boundaries be performed?
strict
logical, should continuity tests be performed-- i.e. for non-contiguous horizon boundaries

Value

  • logical: TRUE --> pass, FALSE --> fail

Details

This function is used as part of the validity-methods for SoilProfileCollection objects.

References

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

See Also

depths<-

Examples

Run this code
# simple example: just one profile
data(sp1)
depths(sp1) <- id ~ top + bottom
s <- horizons(sp1[1, ])

# apply tests
# passes:
test_hz_logic(s, 'top', 'bottom', test.NA=TRUE, strict=FALSE)
# passes:
test_hz_logic(s, 'top', 'bottom', test.NA=TRUE, strict=TRUE)

# add-in some bad data
s$bottom[6] <- NA # missing horizon boundary, common on bottom-most hz
s$bottom[3] <- 30 # inconsistent hz boundary

# apply tests
# fails due to missing hz boundary
test_hz_logic(s, 'top', 'bottom', test.NA=TRUE, strict=FALSE)
# fails due to inconsistent hz boundary
test_hz_logic(s, 'top', 'bottom', test.NA=FALSE, strict=TRUE)

Run the code above in your browser using DataLab