PrintYieldCurves function - grfiv/ustreasuries GitHub Wiki

Given the data returned by the USTreasuryRates function, PrintYieldCurves will produce a plot of one or more yield curves for dates you specify.

format(Sys.Date(), "%A %B %d, %Y")
#> [1] "Monday February 01, 2016"

library(ustreasuries)
all_data = CMTrates()

last_three_years <- dplyr::filter(all_data,
                                    all_data$NEW_DATE>=Sys.Date()-365*3 &
                                    all_data$NEW_DATE<=Sys.Date())
days_per_year <- round(nrow(last_three_years)/3,digits=0)
rows          <- c(1, days_per_year, days_per_year*2, nrow(last_three_years))

PrintYieldCurves(last_three_years,
                 rows  = rows,
                 title = "Yield Curves For The Last Three Years")

Yearly Yield Curves