@@ -47,6 +47,7 @@ write_cid <- function(data, type_name, params)
4747# '
4848# ' @importFrom dplyr bind_rows left_join
4949# ' @importFrom data.table fread
50+ # ' @importFrom stringi stri_extract_first
5051# '
5152# ' @export
5253join_weights <- function (data , params , weights = c(" step1" , " full" ))
@@ -61,6 +62,11 @@ join_weights <- function(data, params, weights = c("step1", "full"))
6162
6263 weights_files <- dir(params $ weights_in_dir , pattern = pattern , full.names = TRUE )
6364 weights_files <- sort(weights_files )
65+
66+ latest_weight <- tail(weights_files , n = 1 )
67+ latest_weight_date <- as.Date(
68+ stri_extract_first(latest_weight , regex = " ^[0-9]{4}-[0-9]{2}-[0-9]{2}" )
69+ )
6470
6571 col_types <- c(" character" , " double" )
6672 col_names <- c(" cid" , " weight" )
@@ -74,5 +80,5 @@ join_weights <- function(data, params, weights = c("step1", "full"))
7480 agg_weights <- agg_weights [! duplicated(cid ),]
7581 data <- left_join(data , agg_weights , by = c(" token" = " cid" ))
7682
77- return (data )
83+ return ( list ( df = data , weight_date = latest_weight_date ) )
7884}
0 commit comments