Learn R Programming

aqp (version 1.7-7)

SoilProfileCollection-class: SoilProfileCollection Class

Description

Basic class for storing soil profile collections, associated site data, and metadata.

Arguments

Objects from the Class

Objects can be created by calls of the form new("SoilProfileCollection", ...).

Examples

Run this code
## use the digest library to detect duplicate data
data(sp1)

# make a copy, make new IDs, and stack
s.1 <- sp1 
s.2 <- sp1
s.2$id <- paste(s.2$id, '-copy', sep='')
s <- rbind(s.1, s.2)
depths(s) <- id ~ top + bottom

# digests are computed from horizon-level data only
# horizon boundaries and 'prop'
# result is an index of unqique profiles
if(require(digest)) {
	u <- unique(s, vars=c('top', 'bottom', 'prop'))
}

# compare with and without dupes:
# note subsetting of SoilProfileCollection
cbind(dupes=length(s), no.dupes=length(s[u, ]))

## 3. 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