dendro.truncate: Truncation of dendrometer data

View source: R/dendro.truncate.R

dendro.truncateR Documentation

Truncation of dendrometer data

Description

Truncates dendrometer data to a user-defined calendar-year and day-of-year window.

The first column of df is treated as the date-time column and is renamed internally to TIME. The date-time column may be a Date, POSIXct, or character vector in the format "yyyy-mm-dd HH:MM:SS". Character dates in the format "yyyy-mm-dd" are also accepted.

This version supports leap years correctly. For example, DOY = 366 is valid for leap years such as 2016, 2020, or 2024, but invalid for non-leap years.

Usage

dendro.truncate(df, CalYear, DOY)

Arguments

df

A data frame where the first column contains date or date-time values. The first column is renamed to TIME in the returned data.

CalYear

Numeric value or numeric vector of length two giving the calendar year or start and end calendar years.

DOY

Numeric value or numeric vector of length two giving the day of year or start and end day of year.

Details

The truncation rules are:

  • If CalYear has length one and DOY has length one, data from that single day are returned.

  • If CalYear has length one and DOY has length two, data from the first DOY to the second DOY within the same year are returned.

  • If CalYear has length two and DOY has length one, data from that DOY in the first year to the same DOY in the second year are returned.

  • If CalYear has length two and DOY has length two, data from the first DOY of the first year to the second DOY of the second year are returned.

The function uses real calendar dates internally rather than row positions. Therefore, leap-year DOY 366 is handled correctly.

Value

A tibble containing the truncated dendrometer data.

Examples


library(dendRoAnalyst)
data(nepa)

# Extract data from DOY 20 to 50 in 2017
trunc1 <- dendro.truncate(df = nepa, CalYear = 2017, DOY = c(20, 50))
head(trunc1, 10)

# Leap-year example, if the data contain year 2020
# trunc2 <- dendro.truncate(df = df2020, CalYear = 2020, DOY = c(1, 366))



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