@@ -25,8 +25,7 @@ tr_yield_curve <- function(date = NULL) {
25
25
if (is.null(dt )) {
26
26
return ()
27
27
}
28
- dt <- clean_yield_curve(dt )
29
- dt
28
+ clean_yield_curve(dt )
30
29
}
31
30
32
31
parse_yield_curve <- function (x ) {
@@ -82,8 +81,7 @@ tr_bill_rates <- function(date = NULL) {
82
81
if (is.null(dt )) {
83
82
return ()
84
83
}
85
- dt <- clean_bill_rates(dt )
86
- dt
84
+ clean_bill_rates(dt )
87
85
}
88
86
89
87
parse_bill_rates <- function (x ) {
@@ -103,8 +101,8 @@ clean_bill_rates <- function(dt) {
103
101
dt [, type : = gsub(" round_b1_" , " " , tolower(type ), fixed = TRUE )]
104
102
dt [, type : = gsub(" _2$" , " " , type )]
105
103
dt [, maturity : = strsplit(type , " _" , fixed = TRUE )]
106
- dt [, type : = vapply(maturity , `[[` , NA_character_ , 1L )]
107
- dt [, maturity : = vapply(maturity , `[[` , NA_character_ , 2L )]
104
+ dt [, type : = vapply(maturity , `[[` , " " , 1L )]
105
+ dt [, maturity : = vapply(maturity , `[[` , " " , 2L )]
108
106
dt [, maturity : = gsub(" wk" , " weeks" , maturity , fixed = TRUE )]
109
107
dt [, c(" date" , " type" , " maturity" , " value" )]
110
108
}
@@ -134,8 +132,7 @@ tr_long_term_rate <- function(date = NULL) {
134
132
if (is.null(dt )) {
135
133
return ()
136
134
}
137
- dt <- clean_long_term_rate(dt )
138
- dt
135
+ clean_long_term_rate(dt )
139
136
}
140
137
141
138
parse_long_term_rate <- function (x ) {
@@ -176,16 +173,15 @@ clean_long_term_rate <- function(dt) {
176
173
# ' \donttest{
177
174
# ' # get data for a single month
178
175
# ' tr_real_yield_curve("202201")
179
- # ' # or for the entire year
180
176
# ' tr_real_yield_curve(2022)
177
+ # ' # or for the entire year
181
178
# ' }
182
179
tr_real_yield_curve <- function (date = NULL ) {
183
180
dt <- treasury(" daily_treasury_real_yield_curve" , date , parse_real_yield_curve )
184
181
if (is.null(dt )) {
185
182
return ()
186
183
}
187
- dt <- clean_real_yield_curves(dt )
188
- dt
184
+ clean_real_yield_curves(dt )
189
185
}
190
186
191
187
parse_real_yield_curve <- function (x ) {
0 commit comments