Add rows of missing dates and fill missing flow values with NA
Adds rows of dates with missing flow values to a streamflow data set with daily flow values of NA. Missing dates will be filled in gaps between data and completely fill the first and last years.
fill_missing_dates( data, dates = Date, values = Value, groups = STATION_NUMBER, station_number, water_year_start = 1, fill_end_years = TRUE )
data |
Data frame of daily data that contains columns of dates, flow values, and (optional) groups (e.g. station numbers).
Leave blank if using |
dates |
Name of column in |
values |
Name of column in |
groups |
Name of column in |
station_number |
Character string vector of seven digit Water Survey of Canada station numbers (e.g. |
water_year_start |
Numeric value indicating the month ( |
fill_end_years |
Logical value indicating whether to fill incomplete start and end years with rows of dates with NA flow values.
If |
A tibble data frame of the source data with additional rows of filled values of missing dates.
# Run if HYDAT database has been downloaded (using tidyhydat::download_hydat()) if (file.exists(tidyhydat::hy_downloaded_db())) { # Fill missing dates with NA using calendar years fill_missing_dates(station_number = "08NM116") # Fill missing dates with NA using water years starting in August fill_missing_dates(station_number = "08NM116", water_year_start = 8) }
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.