transfer_series {rjdworkspace} | R Documentation |
Transfer_series
Description
To copy & paste series from one workspace to another
Usage
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
)
Arguments
ws_from |
The workspace containing the additionnal series |
ws_to |
The workspace to add series to |
selected_series |
The vector containing the series-to-update's names. |
pos_sap_from |
The position of the SA-Processing to transfer the series from |
pos_sap_to |
The position of the SA-Processing to transfer the series to |
name_sap_from |
The name of the SA-Processing to transfer the series from (optional) |
name_sap_to |
The name of the SA-Processing to transfer the series to (optional) |
verbose |
A boolean to print indications on the processing status (optional and TRUE by default) |
create_sap |
A boolean to create a new SA-Processing if not existing (optional) |
replace_series |
A boolean to replace existing series (optional) |
Details
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.
Value
the workspace
ws_to augmented with series present in ws_from and
not already in ws_to
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
)
copy_ws(
ws_name = "ws_input",
from = template_ws,
to = dir_ws
)
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
)
transfer_series(
ws_from = ws_input,
ws_to = ws_output,
pos_sap_from = 1,
pos_sap_to = 1,
verbose = TRUE
)
# 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
)
transfer_series(
ws_from = ws_input, ws_to = ws_output,
pos_sap_from = 2,
pos_sap_to = 2,
verbose = TRUE,
replace_series = TRUE
)
# 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
)
RJDemetra::save_workspace(workspace = ws_output, file = path_ws_to)