YearsMonthsDays: Convert fractional years into a lubridate period object

Description Usage Arguments Value Author(s) Examples

View source: R/BondMath.R

Description

Given a fractional number of years you need to convert into years, months and days to do date math

See the example for the conversion

Usage

1

Arguments

years

Fractional years: 2 years, 3 months, 10 days = 2 + 3/12 + 10/365 = 2.277397

Value

a lubridate period object

Author(s)

George Fisher

Examples

1
2
3
4
5
library(ustreasuries)
(diff_tm <- YearsMonthsDays(2 + 3/12 + 10/365))

# July 1, 2000 plus 2 years (2002), 3 months (10), 10 days (11)
as.Date(lubridate::ymd("2000/07/01") + diff_tm)

grfiv/ustreasuries documentation built on May 17, 2019, 8:36 a.m.