Date to Year-Period Conversion
This function converts an object of class Date()
to an array c(YEAR,PERIOD)
, where YEAR
and PERIOD
are the year-period the input Date()
belongs to, given an input frequency.
date2yp(x = NULL, f = 1)
x |
Input of class |
f |
Positive integer. Valid values are: 1, 2, 3, 4, 12, 24, 36, 53, 366 |
This function returns a two-dimensional array c(YEAR,PERIOD)
.
print(date2yp(as.Date('2001/06/30'),2)) #2001,1 print(date2yp(as.Date('2002/03/23'),1)) #2002,1 print(date2yp(as.Date('2003/07/01'),366)) #2003,182 print(date2yp(as.Date('2004/09/13'),2)) #2004,2 print(date2yp(as.Date('2004/01/13'),12)) #2004,1 print(date2yp(as.Date('2004/07/24'),4)) #2004,3 print(date2yp(c(as.Date('1900-01-01'),as.Date('1944-12-01'), as.Date('1964-06-12'),as.Date('1923-03-01'), as.Date('1943-12-05')),f=366)) #...
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.