# concatenate SoilProfileCollection objects
require(plyr)
d <- ldply(1:10, random_profile)
# promote to SoilProfileCollection and plot
depths(d) <- id ~ top + bottom
plot(d)
# split into new SoilProfileCollection objects by index
d.1 <- d[1, ]
d.2 <- d[2, ]
d.345 <- d[3:5, ]
# recombine, note that profiles are sorted according to ID
d.new <- rbind(d.345, d.1, d.2)
plot(d.new)
# these next examples should throw an error
# insert a missing horizon boundary
data(sp1)
sp1$top[1] <- NA
depths(sp1) <- id ~ top + bottom
Run the code above in your browser using DataLab