yearIndex | R Documentation |
Function to create a year index variable
yearIndex(x)
x |
A vector or column of dates |
# 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.