Pre-conditions data with time information and n-day moving averages
Pre-conditions data with time information and n-day moving averages
Pre-conditions data with time information and n-day moving averages, with options to fill missing days with NA values.
preproc_precondition_data( data =NULL, Date, value, date_format ="%Y-%m-%d", fill_daily =TRUE)
Arguments
data: 'data.frame'. Optional data.frame input, with columns containing Date and value. Column names are specified as strings in the corresponding parameter. Default is NULL.
Date: 'Date' or 'character' vector when data = NULL, or 'character' string identifying Date column name when data is specified. Dates associated with each value in value
parameter.
value: 'numeric' vector when data = NULL, or 'character' string identifying year column name when data is specified. Values to precondition and calculate n-day moving averages from. N-day moving averages only calculated for daily data.
date_format: 'character' string. Format of Date. Default is "%Y-%m-%d".
fill_daily: 'logical' value. Should gaps in Date and value be filled using
preproc_fill_daily. Default is TRUE.
Returns
A data.frame with Date, value, and additional columns with time and n-day moving average information.
Details
These columns are added to the data:
year:
month:
day:
decimal_date:
WY: Water Year: October 1 to September 30
CY: Climate Year: April 1 to March 30
Q3: 3-Day Moving Average: computed at end of moving interval
Q7: 7-Day Moving Average: computed at end of moving interval
Q30: 30-Day Moving Average: computed at end of moving interval
jd: Julian date
This function also checks the time step of the data to make sure that it is daily time step. Daily values with gaps are important to fill with NA to ensure proper calculation of n-day moving averages. Use fill_daily = TRUE or preproc_fill_daily. Other time steps are currently not supported and will return the data.frame without moving averages computed.
Examples
preproc_precondition_data(data = example_obs, Date ="Date", value ="streamflow_cfs")