Description Usage Arguments Details Value Author(s) References See Also Examples
Simple tests for horizon logic, based on a simple data.frame of ordered horizons.
1 | test_hz_logic(i, topcol, bottomcol, strict = FALSE)
|
i |
a data.frame associated with a single soil profile, ordered by depth |
topcol |
character, giving the name of the column in |
bottomcol |
character, giving the name of the column in |
strict |
logical, should continuity tests be performed– i.e. for non-contiguous horizon boundaries |
By default, this function tests for NA and overlapping horizons. If any either are encountered, FALSE is returned.
logical: TRUE –> pass, FALSE –> fail
D.E. Beaudette
http://casoilresource.lawr.ucdavis.edu/
depths<-
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.