Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

extract_layer_output

Extracts values from layer data and organizes layer-wise variables in columns


Description

Convenience function to reorganize soil layer data such as BELO and SWAT to the wide format, by casting variables with the layer number, using data.table's dcast-function.

Usage

extract_layer_output(dat, layers = NULL, value_vars = NULL, sep = "")

Arguments

dat

Data.frame with layer data organized in rows and identified by a layer number column nl.

layers

Integer vector addressing the layer numbers (nl) to be extracted from dat. If not supplied, values from all layers will be returned.

value_vars

Character vector containing names of value-variables to be extracted from dat. If not supplied, value_vars will be guessed.

sep

Separation character for constructig names from variable name and layer index.

Value

A data.table with the layers' values of the variables organized in columns (wide format) with the names being made up of the variable name and layer number.

Examples

# create a data.frame with monthly values
# identifiers: layer number, yr and mo
df <- expand.grid(nl = 1:5,
                  yr = 2002:2003,
                  mo = 1:12)
df
#add a value variable
df$var <- runif(nrow(df), -1,0)

extract_layer_output(df)

# add more variables
df$var1 <- runif(nrow(df), 1,2)
df$var2 <- runif(nrow(df), 2,3)

# extract specific layers
extract_layer_output(df,layers = 2:4, sep = "_")

#extract specific variables
extract_layer_output(df, layers = 2:4, value_vars = c("var1", "var2"), sep = "_")

LWFBrook90R

Simulate Evapotranspiration and Soil Moisture with the SVAT Model LWF-Brook90

v0.4.4
GPL-3
Authors
Paul Schmidt-Walter [aut, cre] (<https://orcid.org/0000-0003-2699-0893>), Volodymyr Trotsiuk [aut] (<https://orcid.org/0000-0002-8363-656X>), Klaus Hammel [aut], Martin Kennel [aut], Anthony Federer [aut], Robert Nuske [ctb] (<https://orcid.org/0000-0001-9773-2061>), Bavarian State Institute of Forestry (LWF) [cph, fnd], Northwest German Forest Research Institute (NW-FVA) [cph, fnd]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.