@@ -64,59 +64,6 @@ flatten_task_list <- function(task_list, .deduplicate = TRUE) {
6464 return (flat_tasks )
6565}
6666
67- # ' Filter to a given vintage of hub target data and drop the `as_of`
68- # ' column.
69- # '
70- # ' This function succeeds silently on unvintaged target data tables
71- # ' provided the user requests the latest available data. Otherwise,
72- # ' it raises an error when the data set is not vintaged.
73- # '
74- # ' @param hub_target_data Table of hub target data to filter
75- # ' @param as_of As of date to filter to. If `"latest"` (default)
76- # ' use the latest available vintage.
77- # ' @param .drop Drop the `as_of` column once the dataset
78- # ' has been filtered to a specific vintage? Default `TRUE`.
79- # ' @return The specific requested vintage of target data,
80- # ' potentially with the `as_of` column removed.
81- hub_target_data_as_of <- function (
82- hub_target_data ,
83- as_of = " latest" ,
84- .drop = TRUE
85- ) {
86- checkmate :: assert_scalar(as_of )
87- vintaged <- " as_of" %in% colnames(hub_target_data )
88- if (vintaged ) {
89- if (as_of == " latest" ) {
90- as_of <- hub_target_data | >
91- dplyr :: summarise(max_date = max(.data $ as_of )) | >
92- dplyr :: collect() | >
93- dplyr :: pull() | >
94- as.Date()
95- }
96- checkmate :: assert_date(as_of )
97- hub_target_data <- dplyr :: filter(
98- hub_target_data ,
99- as.Date(.data $ as_of ) == !! as_of
100- )
101- } else if (as_of != " latest" ) {
102- cli :: cli_abort(
103- " Requested an 'as_of' date other than the default 'latest', " ,
104- " but the provided hubverse target data table does not appear" ,
105- " to be vintaged. It has no 'as_of' column."
106- )
107- }
108-
109- if (.drop ) {
110- hub_target_data <- dplyr :: select(
111- hub_target_data ,
112- - tidyselect :: any_of(" as_of" )
113- )
114- }
115-
116- return (hub_target_data )
117- }
118-
119-
12067# ' Generate and save oracle output for the Hub
12168# '
12269# ' @param hub_path Path to the hub root.
@@ -142,7 +89,7 @@ generate_oracle_output <- function(hub_path) {
14289 dplyr :: mutate(target_end_date = as.Date(.data $ target_end_date ))
14390
14491 target_data <- target_ts | >
145- hub_target_data_as_of(" latest" , .drop = TRUE ) | >
92+ forecasttools :: hub_target_data_as_of(" latest" , .drop = TRUE ) | >
14693 dplyr :: collect() | >
14794 dplyr :: rename(target_end_date = " date" )
14895
0 commit comments