Description Usage Arguments Details Examples
Return the year (fiscal or calendar) and quarter in which the date appears.
1 2 |
x |
vector of type |
firstMonth |
the month corresponding to the first month of the fiscal year (default is October)
Setting |
fy.prefix |
the character string to paste before the year. |
quarter.prefix |
the character string to paste before the quarter. |
sep |
the separater between the year and quarter. |
level.range |
the range to use for defining the levels in the returned factor. |
This function will cut the given date vector into quarters (i.e. three month
increments) and return an ordered factor with levels defined to be the quarters
between the minimum and maximum dates in the given vector. The levels, by
default, will be formated as FY2013-Q1
, however the FY
and Q
can be changed using the fy.prefix
and quarter.prefix
parameters,
respectively.
Original Script can be found at jbryer's Gist site: https://gist.github.com/jbryer/5412193
Here's how to call the function from there directly: gistfile <- "https://gist.github.com/jbryer/5412193" library(devtools) source_gist(gistfile)
The original function has been modified for Federal Calendar (October 1 begins FY of following calendar year)
1 2 3 4 5 6 7 8 9 10 11 | dates <- as.Date(c('2013-04-03','2012-03-30','2011-10-31',
'2011-04-14','2010-04-22','2004-10-04',
'2000-02-29','1997-12-05','1997-04-23',
'1997-04-01'))
nettle_fy(dates)
nettle_fydates, firstMonth=1)
nettle_fy(dates, 1, '', '', '')
## Not run:
nettle_fy(dates, level.range=as.Date(c('2010-01-01','2013-01-01')))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.