# keep examples from using more than 2 cores
data.table::setDTthreads(Sys.getenv("OMP_THREAD_LIMIT", unset = 2))
data(sp1, package = 'aqp')
depths(sp1) <- id ~ top + bottom
site(sp1) <- ~ group
p <- glom(sp1, 25, 150)
# 28 horizons
nrow(p)
# inspect graphically
par(mar = c(1,1,3,1))
plot(p, color = "prop", max.depth = 200)
abline(h = c(25, 100), lty = 2)
## glom(..., truncate = TRUE)
p2 <- glom(sp1, 25, 150, truncate = TRUE)
# 28 horizons
nrow(p2)
# inspect graphically
par(mar = c(1,1,3,1))
plot(p2, color = "prop", max.depth = 200)
abline(h = c(25, 100), lty = 2)
## glom(..., truncate = TRUE, invert = TRUE)
p3 <- glom(sp1, 25, 150, truncate = TRUE, invert = TRUE)
# 45 horizons
nrow(p3)
# inspect graphically
par(mar = c(1,1,3,1))
plot(p3, color = "prop", max.depth = 200)
abline(h = c(25, 100), lty = 2)
## profile-specific interval, using expressions evaluated within sp1@site
# calculate some new site-level variables containing target interval
sp1$glom_top <- (1:9) * 10
sp1$glom_bottom <- 10 + sp1$glom_top
# glom evaluates non-standard expressions using siteNames(sp1) column names
p4 <- glom(sp1, glom_top / 2, glom_bottom * 1.2, truncate = TRUE)
# inspect graphically
par(mar = c(1,1,3,1))
plot(p4, color = "prop", max.depth = 200)
# load sample data
data("sp3")
# promote to SPC
depths(sp3) <- id ~ top + bottom
### TRUNCATE all profiles in sp3 to [0,25]
# set up plot parameters
par(mfrow=c(2,1), mar=c(0,0,0,0))
# full profiles
plot(sp3)
# trunc'd profiles
plot(trunc(sp3, 0, 25))
Run the code above in your browser using DataLab