SPC-utils {aqp}R Documentation

Getters, Setters, and Utility Methods for SoilProfileCollection Objects

Description

Getters, Setters, and Utility Methods for SoilProfileCollection Objects

Methods

signature(object = "SoilProfileCollection")

Author(s)

Dylan E. Beaudette

References

http://casoilresource.lawr.ucdavis.edu/

Examples

data(sp1)

## init SoilProfileCollection objects from data.frame
depths(sp1) <- id ~ top + bottom

## depth units
(du <- depth_units(sp1))
## [1] "cm"
depth_units(sp1) <- 'in'
depth_units(sp1) <- du

## get/set metadata on SoilProfileCollection objects
# this is a 1-row data.frame
m <- metadata(sp1)
## Error in metadata(sp1): no slot of name "history" for this object of class "SoilProfileCollection"
m$sampler <- 'Dylan'
## Error in m$sampler <- "Dylan": object 'm' not found
metadata(sp1) <- m
## Error in eval(expr, envir, enclos): object 'm' not found
## extract horizon data from SoilProfileCollection objects as data.frame
h <- horizons(sp1)

# also replace horizon data in SoilProfileCollection objects
# original order and length must be preserved!
horizons(sp1) <- h

# get number of horizons
nrow(sp1)
## [1] 60
## getting site-level data
site(sp1)
##     id
## 1 P001
## 2 P002
## 3 P003
## 4 P004
## 5 P005
## 6 P006
## 7 P007
## 8 P008
## 9 P009
## setting site-level data
# site-level data from horizon-level data (stored in @horizons)
site(sp1) <- ~ group


# make some fake site data, and append from data.frame
# a matching ID column must be present in both @site and new data
# note that IDs should all be character class
d <- data.frame(id=profile_id(sp1), p=runif(n=length(sp1)), stringsAsFactors=FALSE)
site(sp1) <- d

[Package aqp version 1.9.1 Index]