| year_frac | R Documentation |
year_frac computes year fraction corresponding to a time index.
yf2tind performs the reverse computation.
year_frac(x)
yf2tind(x, type = NULL, tz = NULL)
x |
an object of |
type |
a character value determining time index type
( |
tz |
(optional) a character value determining the time zone (the default
|
year_fraction returns numeric vector representing time indices
in the form year + year fraction. For years this is equivalent to
as.numeric. Year fraction is determined based on the index
within particular year (minus 1 for all indices except for date-time)
and the number of periods within the year.
E.g., 2001Q1 gives 2001 (2001 + (1 - 1) / 4),
2001Q3 — 2001.5 (2001 + (3 - 1) / 4),
2010-04 (April 2010) — 2010.25 (2010 + (4 - 1) / 12),
2000-02-29 (60th day in 2000) — 2000.1612
(2000 + (60 - 1) / 366, 2000 was a leap year).
A numeric vector for year_frac and tind for yf2tind.
Result is of the same length as argument.
year_frac is not to be confused with a similarly called function
(YEARFRAC) found in popular spreadsheet software. In order to compute
differences between dates as year fractions use daycount_frac
function.
daycount_frac.
year_frac(today())
year_frac(now())
yf2tind(2023.5, "y")
yf2tind(2023.5, "q")
yf2tind(2023.5, "m")
yf2tind(2023.5, "w")
yf2tind(2023.5, "d")
yf2tind(2023.5, "t")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.