# example 1
data(jacobs2000)
spc <- jacobs2000
spc$dep_5 <- spc$depletion_pct >=5
spc$genhz <- generalize.hz(spc$name, c("A", "E", "B", "C"), c("A", "E", "B", "C"))
h <- horizons(spc)
test <- hz_dissolve(h, by = c("genhz", "dep_5"), idcol = "id", depthcols = c("top", "bottom"))
vars <- c("id", "top", "bottom", "genhz", "dep_5")
h[h$id == "92-1", vars]
test[test$id == "92-1", ]
# example 2
df <- data.frame(
id = 1,
top = c(0, 5, 10, 15, 25, 50),
bottom = c(5, 10, 15, 25, 50, 100),
hzname = c("A1", "A2", "E/A", "2Bt1", "2Bt2", "2C"),
genhz = c("A", "A", "E", "2Bt", "2Bt", "2C"),
texcl = c("sil", "sil", "sil", "sl", "sl", "s")
)
df
hz_dissolve(df, c("genhz", "texcl"))
hz_dissolve(df, c("genhz", "texcl"), collapse = TRUE)
test <- hz_dissolve(df, "genhz")
subset(test, value == "2Bt")
Run the code above in your browser using DataLab