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
)A data.frame with Date, value, and additional columns with time and n-day moving average information.
'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' 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.
'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.
'character' string. Format of Date. Default is "%Y-%m-%d".
'logical' value. Should gaps in Date and value be filled using
preproc_fill_daily. Default is TRUE.
These columns are added to the data:
yearmonthdaydecimal_dateWYWater Year: October 1 to September 30
CYClimate Year: April 1 to March 30
Q33-Day Moving Average: computed at end of moving interval
Q77-Day Moving Average: computed at end of moving interval
Q3030-Day Moving Average: computed at end of moving interval
jdJulian 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.
preproc_fill_daily, rollmean
preproc_precondition_data(data = example_obs, Date = "Date", value = "streamflow_cfs")
Run the code above in your browser using DataLab