Skip to contents

Calculates the particle size control section weighted average for one or more variables (vars), using upper and lower boundary specified in pscsbounds. Profiles are truncated to the interval set by these bounds, and weighted averages are calculated for each column. The result has the same number of rows as the number of sites in the input SoilProfileCollection x and is suitable for joining back into the site table

Usage

pscs_weighted(
  x,
  vars,
  na.rm = FALSE,
  pscsbounds = c("psctopdepth", "pscbotdepth"),
  prefix = "pscs_"
)

Arguments

x

A SoilProfileCollection

vars

character. Column names of numeric variables in horizon table of x to summarize.

na.rm

logical. Remove NA? Default: FALSE

pscsbounds

character of length 2. Column names of numeric variables in site table representing the profile specific upper and lower boundary. Default: "psctopdepth" and "pscbotdepth"

prefix

character. Prefix to append before column name, to create unique name that does not conflict with existing horizon data. Default: "pscs_"

Value

A data.frame-like object corresponding to aqp_df_class(x)

Examples


# load aqp, and data from soilDB
library(aqp)
#> This is aqp 2.3.2
data(loafercreek, package = "soilDB")

# calculate PSCS weighted clay % and total fragment volume
pscs_cf <- pscs_weighted(loafercreek, c("clay", "fragvoltot"))
#> Error: column names (clay) not found in SoilProfileCollection

# inspect
pscs_cf
#> Error: object 'pscs_cf' not found

# left join to site table of loafercreek
site(loafercreek) <- pscs_cf
#> Error: object 'pscs_cf' not found

loafercreek$pscs_clay
#> NULL