flux_diff: Calculates difference between fluxes

View source: R/flux_diff.R

flux_diffR Documentation

Calculates difference between fluxes

Description

to calculate a flux such as gross ecosystem production (GPP) or transpiration (T) as the difference between other fluxes (such as GPP = NEE - ER). Datetime and other variables to keep will be taken from the type1 measurement. Fluxes not used here (soilR, LRC or other) are not lost.

Usage

flux_diff(
  fluxes_df,
  type_col,
  f_flux = f_flux,
  id_cols,
  type_a,
  type_b,
  diff_name,
  cols_keep = "none"
)

Arguments

fluxes_df

a dataframe containing fluxes

type_col

column containing type of flux

f_flux

column containing flux values

id_cols

columns used to identify each pair of fluxes

type_a

argument designating type_a fluxes in type column

type_b

argument designating type_b fluxes in type column

diff_name

name to give to the new calculated flux

cols_keep

columns to keep from fluxes_df. Values from type_a row will be filled in diff row. none (default) keeps only the columns in id_cols, flux, type and datetime columns; all keeps all the columns; can also be a vector of column names.

Value

a dataframe with $diff = type_a - type_b$ in long format with diff, type_a, and type_b as flux type, datetime, and any column specified in cols_keep. Values of datetime and columns in cols_keep for diff row are taken from type_a measurements.

Examples

data(co2_fluxes)
flux_diff(co2_fluxes, type, id_cols = "turfID", cols_keep = c("temp_soil"),
type_a = "NEE", type_b = "ER", diff_name = "GPP")

fluxible documentation built on Sept. 12, 2025, 1:08 a.m.