dm_daily_clim: Daily climate summaries for dendrometer analyses

View source: R/climate_functions.R

dm_daily_climR Documentation

Daily climate summaries for dendrometer analyses

Description

Computes daily climate summaries from climate time series so they can be related to daily dendrometer summaries from daily.data().

The input can be a standardized climate object returned by read.climate(), a raw data frame, or a valid file path accepted by read.climate().

In addition to same-day climate summaries, the function can also compute lagged and antecedent daily climate features from the summarized daily series:

  • lagged values (e.g. previous 1 or 3 days)

  • antecedent means over previous n days

  • antecedent sums over previous n days

Usage

dm_daily_clim(
  clim_df,
  mean_vars = NULL,
  min_vars = NULL,
  max_vars = NULL,
  sum_vars = NULL,
  median_vars = NULL,
  lag_vars = NULL,
  lagmean_vars = NULL,
  lagsum_vars = NULL,
  lag_days = c(1, 3, 7)
)

Arguments

clim_df

Climate input. This can be:

  • a standardized object returned by read.climate()

  • a raw data frame with a time column in the first column or in a column named TIME

  • a valid file path readable by read.climate()

mean_vars

Character vector of variables to summarize by mean.

min_vars

Character vector of variables to summarize by minimum.

max_vars

Character vector of variables to summarize by maximum.

sum_vars

Character vector of variables to summarize by sum.

median_vars

Character vector of variables to summarize by median.

lag_vars

Character vector of summarized daily climate columns for which simple lagged values should be computed, e.g. c("VPD_max", "SWC_mean").

lagmean_vars

Character vector of summarized daily climate columns for which antecedent means should be computed, e.g. c("Tair_mean", "VPD_mean").

lagsum_vars

Character vector of summarized daily climate columns for which antecedent sums should be computed, e.g. c("P_sum", "Rad_sum").

lag_days

Integer vector giving lag/antecedent window sizes in days, e.g. c(1, 3, 7).

Details

Lagged and antecedent features are calculated from the already summarized daily climate columns. For example, if VPD is included in max_vars, the daily summary column will be VPD_max. If this column is listed in lag_vars and lag_days = 1, then the additional column VPD_max_lag_1d is created.

Antecedent means and sums exclude the current day. For example:

x\_lagmean\_3d(t) = mean(x_{t-3}, x_{t-2}, x_{t-1})

x\_lagsum\_7d(t) = sum(x_{t-7}, \ldots, x_{t-1})

Value

A tibble of class "daily_clim" with one row per day.

Examples


data(ktm_clim_hourly)
clim_day <- dm_daily_clim(
  ktm_clim_hourly,
  mean_vars = c("temp", "VPD", "RH"),
  max_vars  = c("VPD"),
  sum_vars  = c("prec"),
  lag_vars = c("VPD_max", "temp_mean"),
  lagmean_vars = c("temp_mean", "VPD_mean", "RH_mean"),
  lagsum_vars = c("prec_sum"),
  lag_days = c(1, 3, 7)
)
head(clim_day, 5)



dendRoAnalyst documentation built on May 20, 2026, 5:07 p.m.