% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/daily.data.R
\name{daily.data}
\alias{daily.data}
\title{Daily statistics of dendrometer data}
\usage{
daily.data(df, TreeNum)
}
\arguments{
\item{df}{A data frame with the first column containing date-time stamps
convertible to \code{POSIXct} and subsequent columns containing
dendrometer measurements.}

\item{TreeNum}{Integer. The index of the tree (column) to analyze.
\code{TreeNum = 1} refers to the first dendrometer column after the
time column.}
}
\value{
A tibble of class \code{"daily_output"} containing:
\describe{
  \item{DATE}{Calendar date.}
  \item{Min}{Daily minimum value.}
  \item{Time_min}{Time of day of minimum value.}
  \item{Max}{Daily maximum value.}
  \item{Time_max}{Time of day of maximum value.}
  \item{mean}{Daily mean value.}
  \item{median}{Daily median value.}
  \item{amplitude}{Daily amplitude = Max - Min.}
  \item{Time_min_h}{Time of minimum expressed in decimal hours.}
  \item{Time_max_h}{Time of maximum expressed in decimal hours.}
  \item{lag_h}{Signed difference in hours: Time_max_h - Time_min_h.}
  \item{Remarks}{\code{"*"} if \code{Time_max > Time_min}, otherwise \code{""}.}
  \item{Max_diff}{Difference between today's maximum and the previous day's maximum.}
  \item{Day_status}{\code{"growing"}, \code{"shrinking"}, \code{"stable"}, or \code{NA}.}
}
}
\description{
Computes daily statistics from high-frequency dendrometer time series.
For each day, it extracts the minimum and maximum values, their times
of occurrence, daily mean and median, daily amplitude, the signed lag
between the time of maximum and minimum, the day-to-day change in the
daily maximum, and a daily status indicating whether the day is growing,
shrinking, or stable relative to the previous day.
}
\details{
The function requires a data frame with a time column in the first column
and one or more dendrometer series in the following columns. The user
selects the series using \code{TreeNum}.

The returned object has class \code{"daily_output"}, so it can be plotted
directly with \code{plot()}.

The column \code{Max_diff} is computed as:
\deqn{Max\_diff_t = Max_t - Max_{t-1}}

The column \code{Day_status} is derived from \code{Max_diff}:
\itemize{
  \item \code{"growing"} if \code{Max_diff > 0}
  \item \code{"shrinking"} if \code{Max_diff < 0}
  \item \code{"stable"} if \code{Max_diff = 0}
}

The first day has \code{NA} for \code{Max_diff} and \code{Day_status}.
}
\note{
The object returned by \code{daily.data()} can be plotted using
\code{plot()} because it is assigned class \code{"daily_output"}.
}
\examples{
\donttest{
data(nepa17)
daily_stats <- daily.data(df = nepa17[1:1000, ], TreeNum = 1)
head(daily_stats, 10)
}

}
\references{
King G, Fonti P, Nievergelt D, Büntgen U, Frank D (2013)
Climatic drivers of hourly to yearly tree radius variations along a 6°C natural warming gradient.
\emph{Agricultural and Forest Meteorology} 168:36–46.
\doi{10.1016/j.agrformet.2012.08.002}
}
