Computes the base day of the year, a reference value that can be used to group days for the computation of summary statistics. From smwrBase package.
baseDay(x, numeric =TRUE, year = c("calendar","water","climate"))
Arguments
x: a vector of class POSIXt, Dates, or character that represents a date. Missing values are permitted.
numeric: a logical value; TRUE means return the numeric value of the day, FALSE means return a factor.
year: a character string indicating the basis of the factor levels. See Details .
Returns
An integer value representing the base day number if numeric
is TRUE. Otherwise a factor with levels for every day of the year.
Details
The base day is computed such that all dates have the same reference value regardless of whether the year is a leap year or not. If year is "calendar," then the factor levels or day number begin on January 1; if year is "water," then the factor levels or day number begin on October 1; and if year is "climate," then the factor levels or day number begin on April 1.
Examples
# The default numeric resultbaseDay(c("2000-02-29","2000-03-01","2001-03-01"))# The result as a factorbaseDay(c("2000-02-29","2000-03-01","2001-03-01"), numeric=FALSE)