date_fill: Fill gaps in a date sequence

View source: R/dates.R

date_fillR Documentation

Fill gaps in a date sequence

Description

Given a dataframe with one column as a date sequence, fill gaps in the date sequence.

Usage

date_fill(data, date_col, interval = NULL, fill_cols = NULL, add_ymd = FALSE)

Arguments

data

Dataframe

date_col

The column containing dates

interval

The interval in the date sequence. If NULL, calculated automatically.

fill_cols

Columns to fill with the value in the column (should be columns where value is same in every row, such as an ID.)

add_ymd

logical. Should the date be split into year, month, and day columns and added to the output?

Value

Dataframe with filled in dates

Examples

## Not run: 
foo <- data.frame(Date = seq(as.Date("2008-01-01"), as.Date("2008-12-01"), by = "month"), 
                  val = round(rnorm(12, 5, 2), 1), label = rep("a", 12))
bar <- foo[-c(2,5,6,7,10),]
date_fill(bar, "Date", interval = "1 month", fill_cols = "label")

## End(Not run)


bcgov/rcaaqs documentation built on Dec. 12, 2023, 9:21 a.m.