Learn R Programming

aqp (version 0.99-8.56)

SPC-utils: Getters, Setters, and Utility Methods for SoilProfileCollection Objects

Description

Getters, Setters, and Utility Methods for SoilProfileCollection Objects

Arguments

Examples

Run this code
data(sp1)

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

## depth units
(du <- depth_units(sp1))
depth_units(sp1) <- 'in'
depth_units(sp1) <- du

## get/set metadata on SoilProfileCollection objects
# this is a 1-row data.frame
m <- metadata(sp1)
m$sampler <- 'Dylan'
metadata(sp1) <- m

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

	
## getting site-level data
site(sp1)

## setting site-level data
# site-level data from horizon-level data
site(sp1) <- ~ group

# make some fake site data, and append from data.frame
# ordering must match order of profile IDs !!
site(sp1) <- data.frame(p=runif(n=length(sp1)))

# this won't clobber existing data
site(sp1) <- data.frame(p2=runif(n=length(sp1)), p3=runif(n=length(sp1)))

Run the code above in your browser using DataLab