I noticed some unusual output from accumulateDepths() when the source SPC contains NA in the top or bottom depths. Further inspection demonstrated unusual output when top == bottom, modification to depths in the absence of horizon names matching pattern, and when the bottom of an old-style O horizon is not directly adjacent to the top depth of the first mineral horizon.
It would be nice if this function could fail gracefully in the presence of "to little" context, such as when horizon depths are NA or top == bottom.
Test effects of NA:
library(aqp)
x <- quickSPC('01:AAAA|BBBBBBBB|CCCCCCC|CrCrCrCrCr')
# no change - expected
x
accumulateDepths(x)
# all top/bottom set to NA
y <- x
y$top[1] <- NA
accumulateDepths(y)
# unexpected changes to all depths
y <- x
y$bottom[1] <- NA
accumulateDepths(y)
Test effects of modifying either top or bottom depths
# unexpected changes to all depths
y <- x
y$bottom[1] <- 0
accumulateDepths(y)
# unexpected changes to all depths
y <- x
y$bottom[1] <- y$top[1]
accumulateDepths(y)
# unexpected changes to all depths
y <- x
y$bottom[2] <- y$top[2]
accumulateDepths(y)
# unexpected changes to all depths
y <- x
y$top[1] <- 10
y$bottom[1] <- 0
accumulateDepths(y)
# unexpected changes to all depths
y <- x
y$top[1] <- 10
y$bottom[1] <- 0
y$name[1] <- 'O'
accumulateDepths(y)
Test specific problem, a single old-style O horizon with bottom depth matching top depth of next horizon.
# works as expected
y <- x
y$top[1] <- 10
y$bottom[1] <- 0
y$name[1] <- 'O'
y$top[2] <- 0
accumulateDepths(y)
I noticed some unusual output from
accumulateDepths()when the sourceSPCcontains NA in the top or bottom depths. Further inspection demonstrated unusual output whentop == bottom, modification to depths in the absence of horizon names matchingpattern, and when the bottom of an old-style O horizon is not directly adjacent to the top depth of the first mineral horizon.It would be nice if this function could fail gracefully in the presence of "to little" context, such as when horizon depths are NA or
top == bottom.Test effects of
NA:Test effects of modifying either top or bottom depths
Test specific problem, a single old-style O horizon with bottom depth matching top depth of next horizon.