Skip to contents

This function calculates (harmonic-) means of the soilphys dataframe per layer for the flux calculation.

Usage

soilphys_layered(soilphys, layers_map, param, funs, id_cols)

Arguments

soilphys

(dataframe) the soilphys dataframe

layers_map

(dataframe) containing the following parameters:

upper

upper limit of the layer in cm

lower

lower limit of the layer in cm

layer

the name of the layer

...

any id_cols necessary

param

(character vector) A vector containing the names of the variables in soilphys to be carried over

funs

(character vector) A vector defining the type of mean to be used. One of "arith" or "harm"

id_cols

(character vector) A list of all columns, that, together, uniquely identify one profile.

Value

soilphys, reduced to any id_cols and param columns and summarised to the layers provided in layers_map

See also

Examples

data(soildiff)
layers_map <- data.frame(site = rep(c("site_a",
                                      "site_b"),each = 2),
                         upper = c(5,0,7,0),
                         lower = c(0,-100,0,-100),
                         layer = rep(c("HU","M1"),times = 2)
)

soildiff$depth <- (soildiff$upper + soildiff$lower) / 2

soilphys_layered(soilphys = soildiff,
                 layers_map = layers_map,
                 param = c("TPS","a"),
                 funs = c("harm","arith"),
                 id_cols = c("site"))
#> # A tibble: 4 × 6
#> # Groups:   site [2]
#>   site   layer   TPS     a upper lower
#>   <chr>  <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 site_a HU    0.84   0.35     5     0
#> 2 site_a M1    0.397  1.15     0  -100
#> 3 site_b HU    0.8    0.4      7     0
#> 4 site_b M1    0.305  1.03     0  -100