yearIndex: Generate an index of years

View source: R/timeIndices.R

yearIndexR Documentation

Generate an index of years

Description

Function to create a year index variable

Usage

yearIndex(x)

Arguments

x

A vector or column of dates

Examples

# given a vector of dates
df <- data.frame(date = as.Date(c("2017-01-01","2018-04-01","2019-07-01","2019-08-01"),
format = "%Y-%m-%d"))
# calculate the time period variable
df$period <- yearIndex(df$date)
df

IndexNumR documentation built on Nov. 11, 2023, 1:07 a.m.