replace_series() allows to update a selection of series by the same-named series from another workspace. When only the metadata differs, it is the partial version of the update_metadata function.

Generic function to identify and return the duplicates in a list

replace_series(
  ws_from,
  ws_to,
  selected_series,
  mp_from_name,
  mp_to_name,
  verbose = TRUE
)

verif_duplicates(s)

verif_ws_duplicates(ws, verbose = TRUE)

Arguments

ws_from

The workspace containing the most up-to-date version of the selected_series series

ws_to

The workspace to update

selected_series

The vector containing the series-to-update's names.

mp_from_name

The name of the SA-Processing containing the series to update (optional)

mp_to_name

The name of the SA-Processing to update (optional)

verbose

A boolean to print indications on the processing status (optional and TRUE by default)

s

a list of characters

ws

The workspace to scan

Value

the updated workspace

If there are no duplicates, the function returns an empty data frame. Otherwise, it returns a data frame giving the name and number of duplicates found within the argument (list).

a list containing the name and number of occurences of duplicated SAPs and series

Details

If the arguments mp_from_name & mp_to_name are unspecified, the update will be performed using the workspaces' first SAProcessing. If a series is specified in the selected_series vector is missing in a workspace, no replacement will be performed and the function will return the list of missing series. Otherwise, if all is well, the function returns the workspace ws_to updated.

verif_duplicates() identifies and returns the duplicates in a list verif_ws_duplicates() identifies duplicated series in a SAProcessing (SAP) and SAProcessings in a workspace

Examples


library("RJDemetra")
dir_ws <- tempdir()
template_ws <- file.path(system.file("extdata", package = "rjdworkspace"),
                         "WS")
# Moving the WS in a temporary environment
copy_ws(
    ws_name = "ws_output",
    from = template_ws,
    to = dir_ws
)
#> A workspace already exists in the destination folder.
#> It will be rewritten.
#>  Successful copy!
copy_ws(
    ws_name = "ws_input",
    from = template_ws,
    to = dir_ws
)
#>  Successful copy!
path_ws_from <- file.path(dir_ws, "ws_input.xml")
path_ws_to <- file.path(dir_ws, "ws_output.xml")
ws_input <- load_workspace(path_ws_from)
ws_output <- load_workspace(path_ws_to)

replace_series(
    ws_from = ws_input,
    ws_to = ws_output,
    mp_from_name = "SAProcessing-2",
    mp_to_name = "SAProcessing-2",
    selected_series = c("RF1039", "RF1041"),
    verbose = TRUE
)
#> Warning: replace_series is replaced by transfer_series (with replace_series = TRUE).
#>  Functionality remains the same.
#>  The new function add new functionnalities.
#>  Please adjust your code accordingly.
#> pos_mp_to=2pos_mp_from=2
#> Series 1 
#> [1] "RF1039"
#> Done!
#> Series 2 
#> [1] "RF1041"
#> Done!
#> Series updating done for the SAP  SAProcessing-2 .

s <- c("a", "b", "a", "c", "a", "c")
print(rjdworkspace:::verif_duplicates(s))
#>   name Freq
#> 1    a    3
#> 3    c    2