daily_stats: Calculate daily statistics for dendrometer and environmental...

View source: R/daily_stats.R

daily_statsR Documentation

Calculate daily statistics for dendrometer and environmental data

Description

The function calculates various daily statistics for dendrometer and environmental data. It either returns multiple statistics for individual sensors, or a single statistic for multiple sensors.

Usage

daily_stats(dm.data, sensor = 1, value = c("mean", "min",
            "max", "sum"), smooth.param = 1)

Arguments

dm.data

a data.frame with a timestamp (%Y-%m-%d %H:%M:%S format) as row names, and dendrometer series in columns. Output as created using code from the Import dendrometer data vignette, or gap-filled dendrometer series as produced by fill_gaps. Environmental data can be specified as well, and should be formatted as dendrometer data.

sensor

a numeric or character string specifying the sensor(s) to be used in the function. Defaults to 1 (first column of data.frame). If "ALL" is specified, a single value will be calculated or extracted for all series in the data.frame.

value

a character string of "mean", "min", "max" or "sum", specifying the daily statistic to be calculated or extracted. Optional argument for sensor = "ALL", defaults to "mean". Argument matching is performed.

smooth.param

a numeric specifying the degree of smoothing. Defaults to 1 (no smoothing). In case smoothing is applied, series should be gap-free or gap-filled.

Details

The function calculates various daily statistics for dendrometer and environmental data. For sensor is numeric, the function returns multiple statistics for a single sensor. For sensor = "ALL", the function returns a single statistic (i.e. "mean", "min", "max" or "sum") for all columns of the data.frame, whereby "sum" is particularly relevant for environmental parameters like precipitation.

The function includes a smoothing option (argument smooth.param) particularly for noisy datasets in which outliers may under- or overestimate minimum and maximum stem sizes within days. By default, no smoothing is performed. Smoothing requires gap-free series.

Value

The function returns:

  • for sensor is numeric, a data.frame containing the following columns:

dmID

dendrometer ID.

date

timestamp in %Y-%m-%d format.

DOY

day of year.

min

minimum daily stem size.

mean

mean daily stem size.

max

maximum daily stem size.

amplitude

amplitude of daily stem-size changes (i.e. max - min).

time_min

timestamp indicating the timing of the minimum.

time_max

timestamp indicating the timing of the maximum.

  • for sensor is "ALL":

a data.frame with a timestamp (%Y-%m-%d) as row names, and processed dendrometer or environmental data in columns (i.e. mean, minimum, maximum or sum).

Author(s)

Olivier Bouriaud, Ernst van der Maaten and Marieke van der Maaten-Theunissen.

Examples

data(dmCD)
dm.daily <- daily_stats(dmCD, sensor = 1)

data(dmED)
dm.daily <- daily_stats(dmED, sensor = "ALL", value = "max")


smiljanicm/dendrometeR documentation built on April 24, 2023, 2:57 p.m.