dendro.resample: Resampling temporal resolution of dendrometer and climate...

View source: R/dendro.resample.R

dendro.resampleR Documentation

Resampling temporal resolution of dendrometer and climate data

Description

This function changes the temporal resolution of dendrometer and climate time series. It supports both aggregation to coarser resolutions and interpolation to finer resolutions. The target resolution can be defined in minutes, hours, days, weeks, or month-end frequency. Aggregation can be performed using mean, max, min, sum, or count (number of non-missing values). When a finer temporal resolution than the original data is requested, the function can interpolate the series to the new time step using linear interpolation.

Usage

dendro.resample(
  df,
  by,
  value = "mean",
  method = c("auto", "aggregate", "interpolate")
)

Arguments

df

A dataframe with the first column containing date-time values in the format yyyy-mm-dd HH:MM:SS.

by

A character string defining the target temporal resolution. Supported values are:

  • "M" for minutes

  • "H" for hours

  • "D" for days

  • "W" for weeks

  • "ME" for month-end

  • values such as "10M", "30M", "5H", "2D", or "3W" for custom multiples

value

A character string defining the aggregation function. Supported values are "mean", "max", "min", "sum", and "count". The "count" option returns the number of non-NA values within each aggregation interval. It is only valid when method = "aggregate".

method

A character string defining how resampling should be performed. Options are:

  • "auto": automatically aggregates when the requested resolution is coarser than the input data, and interpolates when the requested resolution is finer

  • "aggregate": always aggregates values within each target interval

  • "interpolate": always interpolates to the requested regular time grid

Value

A dataframe with resampled data. The first column contains the new time stamps and the remaining columns contain the resampled variables.

Examples


library(dendRoAnalyst)
data(nepa17)

# Monthly resampling using maximum values
resample_ME <- dendro.resample(df = gf_nepa17, by = "ME", value = "max")
head(resample_ME, 10)

# Daily resampling using mean values
resample_D <- dendro.resample(df = gf_nepa17, by = "D", value = "mean")

# Count non-missing values per day
resample_count <- dendro.resample(df = gf_nepa17, by = "D", value = "count",
                                  method = "aggregate")

# Interpolate to 30-minute resolution
resample_30M <- dendro.resample(df = gf_nepa17, by = "30M", value = "mean",
                                method = "auto")



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