Learn R Programming

aqp (version 2.0.1)

profileInformationIndex: Soil Profile Information Index

Description

A simple index of "information" content associated with individuals in a SoilProfileCollection object. Information content is quantified by number of bytes after gzip compression via memCompress().

Usage

profileInformationIndex(
  x,
  vars,
  method = c("median", "mean", "sum"),
  baseline = TRUE,
  useDepths = TRUE,
  numericDigits = 4
)

Value

a numeric vector of the same length as length(x) and in the same order, suitable for direct assignment to a new site-level attribute

Arguments

x

SoilProfileCollection object

vars

character vector of site or horizon level attributes to consider

method

character: aggregation method, information content evaluated over vars: 'median', 'mean', or 'sum'

baseline

logical, compute ratio to "baseline" information content, see details

useDepths

logical, include horizon depths in vars

numericDigits

integer, number of significant digits to retain in numeric -> character conversion

Author

D.E. Beaudette

Details

Information content via compression (gzip) is the central assumption behind this function: the values associated with a simple soil profile having few horizons and little variation between horizons (isotropic depth-functions) will compress to a much smaller size than a complex profile (many horizons, strong anisotropy). Information content is evaluated a profile at a time, over each site or horizon level attribute specified in vars. Values are aggregated to the profile level by method: median, mean, or sum. The baseline argument invokes a comparison to the simplest possible representation of each depth-function:

  • numeric: replication of the mean value to match the number of horizons with non-NA values

  • character or factor: replication of the most frequent value to match the number of horizons with non-NA values

The ratios computed against a "simple" baseline represent something like "information gain", ranging from 0 to 1. Larger baseline ratios suggest more complexity (more information) associated with a soil profile's depth-functions. Alternatively, the total quantity of information (in bytes) can be determined by setting baseline = FALSE and method = 'sum'.

Examples

Run this code

# simulate three profiles of increasing complexity
p1 <- data.frame(id = 1, top = 0, bottom = 100, p = 5)

p2 <- data.frame(
id = 2, top = c(0, 10, 20, 30, 40, 50), 
bottom = c(10, 20, 30, 40, 50, 100), 
p = rep(5, times = 6)
)

p3 <- data.frame(
id = 3, top = c(0, 10, 20, 30, 40, 50), 
bottom = c(10, 20, 30, 40, 50, 100), 
p = c(1, 5, 10, 3, 6, 2)
)

# combine and upgrade to SPC
z <- rbind(p1, p2, p3)
depths(z) <- id ~ top + bottom

# visual check
plotSPC(z, color = 'p')

# compute information index several ways
profileInformationIndex(z, vars = c('p'), method = 'sum')
profileInformationIndex(z, vars = c('p'), method = 'mean')

profileInformationIndex(z, vars = c('p'), method = 'mean', baseline = FALSE)
profileInformationIndex(z, vars = c('p'), method = 'sum', baseline = FALSE)

Run the code above in your browser using DataLab