yearIndex: Generate an index of years

Description Usage Arguments Examples

View source: R/timeIndices.R

Description

Function to create a year index variable

Usage

1

Arguments

x

A vector or column of dates

Examples

1
2
3
4
5
6
# 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

Example output

        date period
1 2017-01-01      1
2 2018-04-01      2
3 2019-07-01      3
4 2019-08-01      3

IndexNumR documentation built on July 21, 2021, 5:08 p.m.