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.0.3
data(loafercreek, package = "soilDB")

# calculate PSCS weighted clay % and total fragment volume
pscs_cf <- pscs_weighted(loafercreek, c("clay", "fragvoltot"))

# inspect
pscs_cf
#>      peiid pscs_clay pscs_fragvoltot
#> 1   115595  28.76471        0.000000
#> 2   115819  28.76471        0.000000
#> 3   115827  25.88000        0.000000
#> 4   207242  16.00000       16.770270
#> 5   207255  37.32000       21.440000
#> 6   268820  32.63415       13.853659
#> 7   307957  33.78571        1.285714
#> 8   307961  29.57576        7.727273
#> 9   307963  29.00000        8.000000
#> 10  338021  23.02632       30.789474
#> 11  338022  25.28000       19.400000
#> 12  338023  23.36364       37.454545
#> 13  338024  26.25000       11.666667
#> 14  338025  34.12000       34.460000
#> 15  338026  47.69565       13.695652
#> 16  338027  30.73171       23.780488
#> 17  338028  28.32609       25.543478
#> 18  338029  32.00000       10.714286
#> 19  338040  27.12500       26.250000
#> 20  338041  27.76316       22.894737
#> 21  338042  25.00000       14.777778
#> 22  338043  28.60870        5.000000
#> 23  338044  23.39535       27.093023
#> 24  338045  22.32000        5.000000
#> 25  338046  24.10000       26.140000
#> 26  342445  20.91600       29.000000
#> 27  346008  22.52000       29.000000
#> 28  351695  20.48780       31.390244
#> 29  351700  44.38000       25.180000
#> 30  351701  37.88000       11.500000
#> 31  351703  28.70000        7.500000
#> 32  351716  28.80000       54.420000
#> 33  351717  36.46000        4.700000
#> 34  374201  23.78000       44.140000
#> 35  374205  30.72000       17.360000
#> 36  374216  24.33333       35.733333
#> 37  374219  23.76000        6.640000
#> 38  374232  21.78000       12.440000
#> 39  414895  28.72727        9.772727
#> 40  414934  20.83871       15.258065
#> 41  414936  19.56000       32.460000
#> 42  414938  25.48000       23.000000
#> 43  425293  28.92000       16.900000
#> 44  463690  33.95122       35.243902
#> 45  477042  20.18000        5.680000
#> 46  477055  18.86486       48.135135
#> 47  477056  18.12500       69.270833
#> 48  477057  25.56000       20.000000
#> 49  477059  17.34000       23.980000
#> 50  488565  25.84000       31.360000
#> 51  488568  19.00000        5.000000
#> 52  488573  28.37500       30.000000
#> 53  488578  27.10870       50.543478
#> 54  488581  24.72000       24.200000
#> 55  488582  26.20370       55.000000
#> 56  488587  25.13514       52.027027
#> 57  488596  26.00000       50.000000
#> 58  488602  24.38000       43.900000
#> 59  488636  24.20000       16.720000
#> 60  493742  26.24000       23.560000
#> 61  530603  27.44444        0.000000
#> 62  530611  29.90000        5.000000
#> 63  530649        NA        0.880000
#> 64  530692  42.08000       16.100000
#> 65  530693  28.34000       10.000000
#> 66  530694  29.36842       31.052632
#> 67  530699  23.10000        8.500000
#> 68  530731  24.56818       15.000000
#> 69  530740  29.10000       15.000000
#> 70  530744  24.16000        7.200000
#> 71  530751  28.82000       17.200000
#> 72  533172        NA        0.000000
#> 73  533272  18.77500       17.000000
#> 74  533337        NA        0.000000
#> 75  533462  45.82917       23.791667
#> 76  533888  25.25161        5.967742
#> 77  533889        NA       15.000000
#> 78  542093  20.50000       20.000000
#> 79  542095  21.28889       34.000000
#> 80  542125  24.86000        9.280000
#> 81  542129  32.34000        0.000000
#> 82  542130  33.36585       25.804878
#> 83  542131  31.04000       13.560000
#> 84  542153  23.05405       36.108108
#> 85  542154  17.22000        0.000000
#> 86  620521  26.52000       28.300000
#> 87  620522  29.22000       16.820000
#> 88  620523  20.00000       39.642857
#> 89  625813  24.60000       51.620000
#> 90  625821  19.74000       28.620000
#> 91  640607  18.25000       19.375000
#> 92  640610  20.70000        5.900000
#> 93  640616  31.84000        2.000000
#> 94  640625  21.97959        4.387755
#> 95  640629  32.44737       29.078947
#> 96  640630  29.56000       24.400000
#> 97   64505  22.09412        0.000000
#> 98  839192  21.34000       14.900000
#> 99  839203  27.46154        5.538462
#> 100 894094  26.68000        0.000000
#> 101 894095  20.10526        7.105263
#> 102 894118  31.00000        5.000000
#> 103 894145  22.65000       27.750000

# left join to site table of loafercreek
site(loafercreek) <- pscs_cf