h <- data.frame(
id = c(1, 1, 1, 2, 2, 2, 2, 3, 3),
top = c(0:2, 0:3, 0:1) * 10,
bottom = c(rep(NA_integer_, 7), c(10, 99))
)
# NA depths result in warnings
suppressWarnings({
depths(h) <- id ~ top + bottom
})
# inspect data before repairs
plotSPC(h)
g <- repairMissingHzDepths(h)
# all depth logic now valid
all(checkHzDepthLogic(g)$valid)
# inspect
plotSPC(g)
# no adj, max.depth only
f <- repairMissingHzDepths(h, adj = NA, max.depth = 200)
all(checkHzDepthLogic(f)$valid)
plotSPC(f)
# max.depth defaults to max(x) if too small
f$bottom[c(3,7)] <- NA
d <- repairMissingHzDepths(f, adj = NA, max.depth = 20)
all(checkHzDepthLogic(d)$valid)
plotSPC(d)
Run the code above in your browser using DataLab