Skip to content

Commit

Permalink
doc
Browse files Browse the repository at this point in the history
  • Loading branch information
AQLT committed Oct 1, 2023
1 parent 283766d commit 6ddf5b6
Show file tree
Hide file tree
Showing 13 changed files with 122 additions and 23 deletions.
23 changes: 18 additions & 5 deletions R/Cruncher.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,20 @@
#' @param log_file Name of the log file of 'JWSACruncher'. By default the log isn't exported.
#' @encoding UTF-8
#' @return The path to the workspace.
#' @seealso \code{\link{cruncher_and_param}}, \code{\link{update_workspace}}.
#' @seealso Around the 'JWSACruncher': [cruncher_and_param()], [update_workspace()].
#' To create the parameter file: [create_param_file()] and [list2param_file()].
#' @examples
#' \dontrun{
#' dir = tempdir()
#' # First create a parameter file
#' # here a file parameters.param is created in the directory dir
#' # with default parameters of 'JWSACruncher' v2
#' list2param_file(dir, default_param_file(v3 = FALSE))
#' # If the option "cruncher_bin_directory" is correctly defined:
#' cruncher("workspace.xml",
#' param_file_path = file.path(dir, "parameters.param"))
#' }
#'
#' @export
cruncher <- function(workspace,
cruncher_bin_directory = getOption("cruncher_bin_directory"),
Expand Down Expand Up @@ -100,8 +113,8 @@ cruncher <- function(workspace,
#' By default \code{rename_multi_documents = FALSE}: the names of the XML files of the multi-documents are used.
#' @param delete_existing_file Only used if \code{rename_multi_documents = TRUE}. Boolean indicating whether to
#' delete existing folders when renaming them. By default (\code{delete_existing_file = FALSE}) they are not deleted.
#' @param ... Other parameters of \link{create_param_file}.
#' @seealso \code{\link{cruncher}}, \code{\link{update_workspace}}, \code{\link{create_param_file}}, \code{\link{multiprocessing_names}}.
#' @param ... Other parameters of [create_param_file()].
#' @seealso [cruncher()], [update_workspace()], [create_param_file()], [multiprocessing_names()].
#' @encoding UTF-8
#' @return Path to the workspace.
#' @export
Expand Down Expand Up @@ -156,7 +169,7 @@ cruncher_and_param <- function(workspace = NULL,
#' @encoding UTF-8
#' @return A \code{data.frame} containing the name of the multiprocessings that appears on 'JDemetra+' (column \code{name}) and
#' the name of the associated XML files (column \code{file}).
#' @seealso \code{\link{cruncher_and_param}}.
#' @seealso [cruncher_and_param()].
#' @export
multiprocessing_names <- function(workspace){
if (missing(workspace) || is.null(workspace)) {
Expand Down Expand Up @@ -196,7 +209,7 @@ multiprocessing_names <- function(workspace){
#' @inheritParams create_param_file
#' @encoding UTF-8
#' @return Path to the workspace.
#' @seealso \code{\link{cruncher}}, \code{\link{cruncher_and_param}}.
#' @seealso [cruncher()], [cruncher_and_param()].
#' @export
update_workspace <- function(workspace = NULL,
policy = "parameters",
Expand Down
4 changes: 2 additions & 2 deletions R/download_cruncher.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#' # To download the release of the version 2.2.2:
#' download_cruncher(dir, "2.2.2")
#' }
#' @seealso \code{\link{configure_jwsacruncher}}.
#' @seealso [configure_jwsacruncher()].
#' @export
download_cruncher <- function(directory, cruncher_version, v3 = getOption("is_cruncher_v3")){
if (missing(directory)) {
Expand Down Expand Up @@ -109,7 +109,7 @@ download_cruncher <- function(directory, cruncher_version, v3 = getOption("is_cr
#' }
#' The function \code{configure_jwsacruncher()} does the steps 2 and 3.
#'
#' @seealso \code{\link{download_cruncher}}.
#' @seealso [download_cruncher()].
#' @encoding UTF-8
#' @export
configure_jwsacruncher <- function(jwsacruncher_path, java_path){
Expand Down
42 changes: 37 additions & 5 deletions R/param_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,19 @@
#' }
#'
#' @return Path to the parameter file.
#' @seealso \code{\link{cruncher_and_param}}.
#' @seealso [read_param_file()], [list2param_file()], [default_param_file] [cruncher_and_param()].
#' @encoding UTF-8
#' @examples
#' \dontrun{
#' dir = tempdir()
#' # Here a file parameters.param is created in the directory dir
#' # with default parameters of the different options
#' create_param_file(dir)
#' # to only export the raw and the seasonally adjusted series
#' create_param_file(dir,
#' tsmatrix_series = c("y", "sa"))
#' }
#'
#' @export
create_param_file <- function(
dir_file_param, bundle = 10000, csv_layout = "list", csv_separator = ";",
Expand Down Expand Up @@ -92,9 +103,17 @@ create_param_file <- function(
return(invisible(paste0(dir_file_param,"/parameters.param")))
}

#' Create parameter file for the 'JWSACruncher'
#' Read parameter file of the 'JWSACruncher'
#'
#' @param file Path to the parameter file.
#'
#' @seealso [create_param_file()], [list2param_file()], [default_param_file()] [cruncher_and_param()].
#' @examples
#' dir = tempdir()
#' list_param <- default_param_file(v3 = FALSE)
#' list2param_file(dir, list_param)
#' list_param_2 <- read_param_file(file.path(dir, "parameters.param"))
#' all.equal(list_param, list_param_2)
#' @export
read_param_file <- function(file){
f <- readLines(file)
Expand Down Expand Up @@ -127,7 +146,7 @@ read_param_file <- function(file){
refreshall <- grep("refreshall", f, value = TRUE)
if (length(refreshall) > 0) {
refreshall <- gsub("(.*<refreshall>)|(</.*)", "", refreshall)
refreshall <- refreshall == '"true"'
refreshall <- refreshall == 'true'
} else {
refreshall <- NULL
}
Expand Down Expand Up @@ -175,8 +194,20 @@ read_param_file <- function(file){
#' Create parameter file from list
#'
#' @inheritParams create_param_file
#' @param x A list, for example create by \code{\link{read_param_file}} or \code{\link{default_param_file}}.
#'@export
#' @param x A list, for example create by [read_param_file()] or [default_param_file()].
#' @seealso [create_param_file()], [read_param_file()], [default_param_file()] [cruncher_and_param()].
#' @examples
#' \dontrun{
#' dir = tempdir()
#' # Here a file parameters.param is created in the directory dir
#' # with default parameters of 'JWSACruncher' v2
#' list_param <- default_param_file(v3 = FALSE)
#' list2param_file(dir, list_param)
#' # to only export the raw and the seasonally adjusted series
#' list_param$tsmatrix_series <- c("y", "sa")
#' list2param_file(dir, list_param)
#' }
#' @export
list2param_file <- function(dir_file_param, x){
config <- x$config
v3 <- !is.null(config$format)
Expand All @@ -190,6 +221,7 @@ list2param_file <- function(dir_file_param, x){
#'
#' @param v3 Boolean indicating if the parameters are the from a version 3.0.0 and higher of 'JWSACRuncher' (\code{v3 = TRUE}) or a lower version (\code{v3 = FALSE}). By default
#' the value of the option \code{"is_cruncher_v3"} is used (equals to \code{FALSE} by default).
#' @seealso [create_param_file()], [read_param_file()], [list2param_file()], [cruncher_and_param()].
#' @export
default_param_file <- function(v3 = getOption("is_cruncher_v3")){
v3_param <-
Expand Down
2 changes: 1 addition & 1 deletion man/configure_jwsacruncher.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion man/create_param_file.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion man/cruncher.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/cruncher_and_param.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/default_param_file.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/download_cruncher.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion man/list2param_file.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/multiprocessing_names.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions man/read_param_file.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/update_workspace.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6ddf5b6

Please sign in to comment.