Skip to content

Commit 6b9e2eb

Browse files
committed
short column headers parameter
1 parent 96a16dc commit 6b9e2eb

File tree

4 files changed

+46
-22
lines changed

4 files changed

+46
-22
lines changed

NEWS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# rjwsacruncher 0.2.2
2+
3+
- add new parameter `short_column_headers` to `create_param_file()`.
4+
5+
- correction of `default_param_file()` when `cruncher_bin_directory` is defined.
6+
7+
- if the default parameter file of the 'JWSACruncher' already exists, `default_param_file()` do not erase and delete it when `cruncher_bin_directory` is defined.
8+
19
# rjwsacruncher 0.2.1
210

311
- parameters `rename_multi_documents` and `renaming_existing_files` added in `cruncher()` function.

R/param_file.R

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#' @param ndecs Number of decimals used in the output. By default \code{ndec = 6}.
1212
#' @param full_series_name Boolean indicating if the fully qualified name of the series will be used (the default \code{full_series_name = TRUE}) or if only the name of the series should be displayed.
1313
#' Only used when \code{v3 = TRUE}.
14+
#' @param short_column_headers Boolean indicating if the full column names should be printed (the default `short_column_headers = TRUE`) instead of always outputting shortened ones.
15+
#' Only used when \code{v3 = TRUE} (since v.3.4.0).
1416
#' @param rslt_name_level Only used when \code{v3 = TRUE}.
1517
#' @param policy Refreshing policy of the processing. By default \code{policy = "parameters"} (re-estimation of the coefficients of the reg-ARIMA model, see details).
1618
#' @param refreshall Boolean indicating if the data is refreshed (by default `refreshall = TRUE`).
@@ -25,7 +27,7 @@
2527
#' \item \code{policy = "current"}: all the estimations are fixed and AO added for new data (since v.2.2.3), short name `policy = "n"`;
2628
#' \item \code{policy = "fixed"}: all the estimations are fixed (since v.2.2.3), short name `policy = "f"`;
2729
#' \item \code{policy = "fixedparameters"}: re-estimation of the coefficients of the regression variables (but not the ARIMA coefficients), short name `policy = "fp"`;
28-
#' \item \code{policy = "fixedarparameters"}: re-estimation of the coefficients of the regression variables and of the MA coefficients of the ARIMA model (but not the AR coefficients), short name `policy = "farp"` (since v.3.3.1);
30+
#' \item \code{policy = "fixedarparameters"}: re-estimation of the coefficients of the regression variables and of the MA coefficients of the ARIMA model (but not the AR coefficients), short name `policy = "farp"` (since v.3.4.0);
2931
#' \item \code{policy = "parameters"} (the default): \code{policy = "fixedparameters"} + re-estimation of ARIMA coefficients, short name `policy = "p"`;
3032
#' \item \code{policy = "lastoutliers"}: \code{policy = "parameters"} + re-identification of last outliers (on the last year), short name `policy = "l"`;
3133
#' \item \code{policy = "outliers"}: \code{policy = "lastoutliers"} + re-identification of all outliers, short name `policy = "o"`;
@@ -50,7 +52,7 @@
5052
#' @export
5153
create_param_file <- function(
5254
dir_file_param, bundle = 10000, csv_layout = "list", csv_separator = ";",
53-
ndecs = 6, full_series_name = TRUE, rslt_name_level = 2, policy = "parameters", refreshall = TRUE,
55+
ndecs = 6, full_series_name = TRUE, short_column_headers = TRUE, rslt_name_level = 2, policy = "parameters", refreshall = TRUE,
5456
output = NULL,
5557
matrix_item = getOption("default_matrix_item"),
5658
tsmatrix_series = getOption("default_tsmatrix_series"),
@@ -67,6 +69,7 @@ create_param_file <- function(
6769
if (v3){
6870
param_line <- paste(param_line,
6971
" fullseriesname=", ifelse(full_series_name, "true", "false"),
72+
" shortcolumnheaders=", ifelse(short_column_headers, "true", "false"),
7073
" rsltnamelevel=", rslt_name_level,
7174
" format=",
7275
"JD3", sep = "\"")
@@ -137,11 +140,15 @@ read_param_file <- function(file){
137140
})
138141
list_config <- gsub("csv", "csv_", list_config)
139142
list_config <- gsub("fullseriesname", "full_series_name", list_config)
143+
list_config <- gsub("shortcolumnheaders", "short_column_headers", list_config)
140144
list_config <- gsub("rsltnamelevel", "rslt_name_level", list_config)
141145
names(config) <- list_config
142146
if (!is.null(config$full_series_name)) {
143147
config$full_series_name <- config$full_series_name == '"true"'
144148
}
149+
if (!is.null(config$short_column_headers)) {
150+
config$short_column_headers <- config$short_column_headers == '"true"'
151+
}
145152
policy <- grep("policy", f, value = TRUE)
146153
if (length(policy) > 0) {
147154
policy <- gsub("(.*<policy>)|(</.*)", "", policy)
@@ -242,7 +249,9 @@ default_param_file <- function(v3 = getOption("is_cruncher_v3"), cruncher_bin_di
242249
v3_param <-
243250
list(
244251
config = list(bundle = "10000", csv_layout = "list", csv_separator = ";",
245-
ndecs = "6", full_series_name = TRUE, rslt_name_level = "2",
252+
ndecs = "6", full_series_name = TRUE,
253+
short_column_headers = TRUE,
254+
rslt_name_level = "2",
246255
format = "JD3"),
247256
policy = "parameters", refreshall = TRUE,
248257
output = NULL,
@@ -495,24 +504,27 @@ default_param_file <- function(v3 = getOption("is_cruncher_v3"), cruncher_bin_di
495504
if(! is.null(cruncher_bin_directory)) {
496505
if (!file.exists(file.path(cruncher_bin_directory,"jwsacruncher")))
497506
stop (sprintf("JWSACruncher not found in %s.\n Check the installation", paste0(cruncher_bin_directory,"/jwsacruncher")))
498-
wd <- getwd()
499-
setwd(cruncher_bin_directory)
500-
on.exit(setwd(wd))
501-
os <- Sys.info()[['sysname']]
502-
if (os == "Windows") {
503-
log <- system(
504-
"jwsacruncher", intern = TRUE)
505-
} else {
506-
# Mac OS and linux
507-
log <- system(
508-
"./jwsacruncher",
509-
intern = TRUE)
507+
param_file <- file.path(cruncher_bin_directory, "wsacruncher.params")
508+
exists_param_file <- file.exists(param_file)
509+
if (!exists_param_file) {
510+
wd <- getwd()
511+
setwd(cruncher_bin_directory)
512+
on.exit(setwd(wd))
513+
os <- Sys.info()[['sysname']]
514+
if (os == "Windows") {
515+
log <- system(
516+
"jwsacruncher", intern = TRUE)
517+
} else {
518+
# Mac OS and linux
519+
log <- system(
520+
"./jwsacruncher",
521+
intern = TRUE)
522+
}
510523
}
511-
res <- rjwsacruncher::read_param_file(file.path(cruncher_bin_directory, "wsacruncher.params"))
512-
file.remove(file.path(cruncher_bin_directory, "wsacruncher.params"))
513-
}
514-
515-
if (v3) {
524+
res <- read_param_file(param_file)
525+
if (!exists_param_file)
526+
file.remove(param_file)
527+
} else if (v3) {
516528
res <- v3_param
517529
} else {
518530
res <- v2_param

man/create_param_file.Rd

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vignettes/run_jwsacruncher.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Description = c(
7777
"The ARIMA model, outliers and other regression parameters are not re-identified and the values of all parameters are fixed. The transformation type remains unchanged. An additive outlier (AO) is added for new data. (since v.2.2.3)",
7878
"The ARIMA model, outliers and other regression parameters are not re-identified and the values of all parameters are fixed. The transformation type remains unchanged. (since v.2.2.3)",
7979
"The ARIMA model, outliers and other regression parameters are not re-identified. The coefficients of the ARIMA model are fixed, other coefficients are re-estimated. The transformation type remains unchanged.",
80-
"The ARIMA model, outliers and other regression parameters are not re-identified. The AR coefficients of the ARIMA model are fixed, other coefficients are re-estimated (MA coefficients + regressors). The transformation type remains unchanged. (since v.3.3.1)",
80+
"The ARIMA model, outliers and other regression parameters are not re-identified. The AR coefficients of the ARIMA model are fixed, other coefficients are re-estimated (MA coefficients + regressors). The transformation type remains unchanged. (since v.3.4.0)",
8181
"The ARIMA model, outliers and other regression parameters are not re-identified. All parameters of the RegARIMA model are re-estimated. The transformation type remains unchanged.",
8282
"The ARIMA model, outliers (except from the outliers in the last year of the sample) and other regression parameters are not re-identified. All parameters of the RegARIMA model are re-estimated. The outliers in the last year of the sample are re-identified. The transformation type remains unchanged.",
8383
"The ARIMA model and regression parameters, except from outliers) are not re-identified. All parameters of the RegARIMA model are re-estimated. All outliers are re-identified. The transformation type remains unchanged.",

0 commit comments

Comments
 (0)