To copy & paste series from one workspace to another
transfer_series(
ws_from,
ws_to,
selected_series,
pos_sap_from,
pos_sap_to,
name_sap_from,
name_sap_to,
verbose = TRUE,
create_sap = TRUE,
replace_series = TRUE
)
The workspace containing the additionnal series
The workspace to add series to
The vector containing the series-to-update's names.
The position of the SA-Processing to transfer the series from
The position of the SA-Processing to transfer the series to
The name of the SA-Processing to transfer the series from (optional)
The name of the SA-Processing to transfer the series to (optional)
A boolean to print indications on the processing status (optional and TRUE by default)
A boolean to create a new SA-Processing if not existing (optional)
A boolean to replace existing series (optional)
the workspace
ws_to augmented with series present in ws_from and
not already in ws_to
To use this function you need to first launch load_workspace
and after
save_workspace
to save the changes.
name_sap_to
and name_sap_from
refer to the SAP's name and not SAP's
file's name.
The transfer will fail if:
- name_sap_from
doesn't exist
- pos_sap_from
< 0 or exceed the maximum number of SAP
- pos_sap_to
< 0 or exceed the maximum number of SAP
- The arguments pos_sap_from
and name_sap_from
are refering to
differents objects.
- The arguments pos_sap_to
and name_sap_to
are refering to
differents objects.
If name_sap_to
and pos_sap_to
are unspecified, the update will be
performed using the workspaces' first SAProcessing (same for the SAP from).
However if the informations of one on the two SAP (from or to) are specified
(name or position), they will be attributed by default to the other
worskpace.
If name_sap_to
doesn't refer to an existing SAP, a new SAP will be created
(if create_sap
is TRUE
).
If a sa_item has a specification which uses external regressor, you have to be sure that the regressors are also in the destination workspace.
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
)
#> A workspace already exists in the destination folder.
#> It will be rewritten.
#> 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)
# Existing SAP
transfer_series(
ws_from = ws_input,
ws_to = ws_output,
name_sap_from = "SAProcessing-1",
name_sap_to = "SAProcessing-1",
verbose = TRUE
)
#> First WS's SAP :
#> - name : SAProcessing-1
#> - pos : 1
#> and
#> Second WS's SAP :
#> - name : SAProcessing-1
#> - pos : 1
#>
#> Series n°1, name: RF0610, position: 1 - to add... Successful transfer!
#> Series n°2, name: RF0620, position: 2 - to add... Successful transfer!
#> Series n°3, name: RF0811, position: 3 - to add... Successful transfer!
#> Series n°4, name: RF0812, position: 4 - to add... Successful transfer!
#> Series n°5, name: RF0893, position: 5 - to add... Successful transfer!
#> Series n°6, name: RF0899, position: 6 - to add... Successful transfer!
#>
#> Done!
transfer_series(
ws_from = ws_input,
ws_to = ws_output,
pos_sap_from = 1,
pos_sap_to = 1,
verbose = TRUE
)
#> First WS's SAP :
#> - name : SAProcessing-1
#> - pos : 1
#> and
#> Second WS's SAP :
#> - name : SAProcessing-1
#> - pos : 1
#>
#> Series n°1, name: RF0610, position: 1 - to replace... Successful transfer!
#> Series n°2, name: RF0620, position: 2 - to replace... Successful transfer!
#> Series n°3, name: RF0811, position: 3 - to replace... Successful transfer!
#> Series n°4, name: RF0812, position: 4 - to replace... Successful transfer!
#> Series n°5, name: RF0893, position: 5 - to replace... Successful transfer!
#> Series n°6, name: RF0899, position: 6 - to replace... Successful transfer!
#>
#> Done!
# Existing series
transfer_series(
ws_from = ws_input, ws_to = ws_output,
pos_sap_from = 2,
pos_sap_to = 2,
verbose = TRUE,
replace_series = FALSE
)
#> First WS's SAP :
#> - name : SAProcessing-2
#> - pos : 2
#> and
#> Second WS's SAP :
#> - name : SAProcessing-2
#> - pos : 2
#>
#> Series n°1, name: RF0812, position: 1 - to add... Successful transfer!
#> Series n°2, name: RF0893, position: 2 - to add... Successful transfer!
#> Series n°3, name: RF0899, position: 3 - to add... Successful transfer!
#>
#> Done!
transfer_series(
ws_from = ws_input, ws_to = ws_output,
pos_sap_from = 2,
pos_sap_to = 2,
verbose = TRUE,
replace_series = TRUE
)
#> First WS's SAP :
#> - name : SAProcessing-2
#> - pos : 2
#> and
#> Second WS's SAP :
#> - name : SAProcessing-2
#> - pos : 2
#>
#> Series n°1, name: RF0812, position: 1 - to replace... Successful transfer!
#> Series n°2, name: RF0893, position: 2 - to replace... Successful transfer!
#> Series n°3, name: RF0899, position: 3 - to replace... Successful transfer!
#> Series n°4, name: RF1039, position: 4 - to replace... Successful transfer!
#> Series n°5, name: RF1041, position: 5 - to replace... Successful transfer!
#> Series n°6, name: RF1042, position: 6 - to replace... Successful transfer!
#>
#> Done!
# Create a new SAP
# transfer_series(ws_from = ws_input, ws_to = ws_output,
# name_sap_from = "SAProcessing-1",
# name_sap_to = "New-SAProcessing-from-R",
# verbose = TRUE,
# create = FALSE)
transfer_series(
ws_from = ws_input, ws_to = ws_output,
name_sap_from = "SAProcessing-1",
name_sap_to = "New-SAProcessing-from-R",
verbose = TRUE,
create = TRUE
)
#> A new SAP named New-SAProcessing-from-R in ws_to will be created.
#> First WS's SAP :
#> - name : SAProcessing-1
#> - pos : 1
#> and
#> Second WS's SAP :
#> - name : New-SAProcessing-from-R
#> - pos : 4
#>
#> Series n°1, name: RF0610, position: 1 - to add... Successful transfer!
#> Series n°2, name: RF0620, position: 2 - to add... Successful transfer!
#> Series n°3, name: RF0811, position: 3 - to add... Successful transfer!
#> Series n°4, name: RF0812, position: 4 - to add... Successful transfer!
#> Series n°5, name: RF0893, position: 5 - to add... Successful transfer!
#> Series n°6, name: RF0899, position: 6 - to add... Successful transfer!
#>
#> Done!
RJDemetra::save_workspace(workspace = ws_output, file = path_ws_to)