Skip to content

Commit c5ae849

Browse files
committed
refactor: rename tr_bill_rates() to tr_bill_rate() to match other function names
1 parent ce662fc commit c5ae849

File tree

10 files changed

+27
-24
lines changed

10 files changed

+27
-24
lines changed

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Generated by roxygen2: do not edit by hand
22

3-
export(tr_bill_rates)
3+
export(tr_bill_rate)
44
export(tr_curve_rate)
55
export(tr_forward_rate)
66
export(tr_long_term_rate)

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# treasury (development version)
22

3+
* Better documentation.
4+
* Rename `tr_bill_rates()` to `tr_bill_rate()` to match rest of function names.
5+
36
# treasury 0.3.0
47

58
* Migration to data.table package. Internal data manipulation is now done using

R/interest-rate.R

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ clean_yield_curve <- function(dt) {
4747
dt[, maturity := gsub("(\\d+)(\\w+)", "\\1 \\2", maturity)][]
4848
}
4949

50-
#' Daily treasury bill rates
50+
#' Daily treasury bill rate
5151
#'
5252
#' @description
5353
#' These rates are the daily secondary market quotations on the most recently
@@ -72,19 +72,19 @@ clean_yield_curve <- function(dt) {
7272
#' @examples
7373
#' \donttest{
7474
#' # get data for a single month
75-
#' tr_bill_rates("202201")
75+
#' tr_bill_rate("202201")
7676
#' # or for the entire year
77-
#' tr_bill_rates(2022)
77+
#' tr_bill_rate(2022)
7878
#' }
79-
tr_bill_rates <- function(date = NULL) {
80-
dt <- treasury("daily_treasury_bill_rates", date, parse_bill_rates)
79+
tr_bill_rate <- function(date = NULL) {
80+
dt <- treasury("daily_treasury_bill_rates", date, parse_bill_rate)
8181
if (is.null(dt)) {
8282
return()
8383
}
84-
clean_bill_rates(dt)
84+
clean_bill_rate(dt)
8585
}
8686

87-
parse_bill_rates <- function(x) {
87+
parse_bill_rate <- function(x) {
8888
date <- x |>
8989
xml2::xml_find_all(".//d:INDEX_DATE") |>
9090
xml2::xml_text() |>
@@ -97,7 +97,7 @@ parse_bill_rates <- function(x) {
9797
)
9898
}
9999

100-
clean_bill_rates <- function(dt) {
100+
clean_bill_rate <- function(dt) {
101101
dt[, type := gsub("round_b1_", "", tolower(type), fixed = TRUE)]
102102
dt[, type := gsub("_2$", "", type)]
103103
dt[, maturity := strsplit(type, "_", fixed = TRUE)]

_pkgdown.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ template:
77
reference:
88
- subtitle: Interest Rates
99
contents:
10-
- tr_yield_curve
11-
- tr_bill_rates
10+
- tr_bill_rate
1211
- tr_long_term_rate
13-
- tr_real_yield_curve
1412
- tr_real_long_term
13+
- tr_real_yield_curve
14+
- tr_yield_curve
1515

1616
- subtitle: Treasury Coupon Issues and Corporate Bond Yield Curve
1717
contents:

man/tr_bill_rates.Rd renamed to man/tr_bill_rate.Rd

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/tr_long_term_rate.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/tr_real_long_term.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/tr_real_yield_curve.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/tr_yield_curve.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-interest-rate.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
test_that("input validation works", {
22
fns <- list(
33
tr_yield_curve,
4-
tr_bill_rates,
4+
tr_bill_rate,
55
tr_long_term_rate,
66
tr_real_yield_curve,
77
tr_real_long_term
@@ -75,7 +75,7 @@ test_that("clean_bill_rates works", {
7575
"ROUND_B1_YIELD_52WK_2"
7676
)
7777
data <- data.table(date = date, type = type, value = rate)
78-
actual <- clean_bill_rates(data)
78+
actual <- clean_bill_rate(data)
7979
type <- rep(c("close", "yield"), 5L)
8080
maturity <- c(
8181
"4 weeks",

0 commit comments

Comments
 (0)