Add temporal bins to a dataframe

bin_date(df, date_col = "date", bin = c("year", "month"))

Arguments

df

Dataframe, with date_col, to be augmented with temporal bins

date_col

Character. Name of column in df containing dates

bin

Character or dataframe. If character, any lubridate package method(s) such as year for lubridate::year() or month for lubridate::month(). If dataframe, it must contain a date_col column with a match for every instance in df data_col (or at least every instance needed in a temporal bin).

Value

df with extra columns from bin