Skip to content

Commit

Permalink
Merge pull request #20 from TanguyBarthelemy/master
Browse files Browse the repository at this point in the history
resolve a bug
  • Loading branch information
TanguyBarthelemy authored Sep 8, 2023
2 parents bff4c1d + a881abd commit 5f31ff8
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 77 deletions.
5 changes: 5 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@
^pkgdown$
^doc$
^Meta$
^NEWS.html$
^TO_DO$
^LICENCE$
^LICENSE$
^.github$
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Suggests:
knitr,
kableExtra,
rmarkdown
License: file LICENSE
License: EUPL
VignetteBuilder: knitr
Encoding: UTF-8
LazyData: true
Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion R/Cruncher.R
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ multiprocessing_names <- function(workspace) {
stop("The workspace doesn't exist")

xml_workspace <- suppressWarnings(XML::xmlParse(workspace, error = function(...) {}))
noms_objets <- XML::xmlToDataFrame(nodes = XML::getNodeSet(doc = xml_workspace, path = "//ns2:demetraGenericWorkspace/ns2:items/ns2:item"))
noms_objets <- XML::xmlToDataFrame(nodes = XML::getNodeSet(
doc = xml_workspace,
path = "//ns2:demetraGenericWorkspace/ns2:items/ns2:item"))
noms_multi_documents <- noms_objets[grep("multi-documents", noms_objets$family), ]
noms_multi_documents <- noms_multi_documents[, c("name", "file")]

Expand Down
3 changes: 1 addition & 2 deletions R/QR_export.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ export_xlsx.QR_matrix <- function(x, layout = c("all", "modalities", "values", "
XLConnect::clearSheet(wb, sheets)
}

XLConnect::setStyleAction(wb,
XLConnect::XLC$STYLE_ACTION.DATA_FORMAT_ONLY)
XLConnect::setStyleAction(wb, XLConnect::XLC$STYLE_ACTION.DATA_FORMAT_ONLY)
if (auto_format) {
XLConnect::setDataFormatForType(wb,
type = XLConnect::XLC$DATA_TYPE.NUMERIC,
Expand Down
91 changes: 49 additions & 42 deletions R/QR_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -136,25 +136,26 @@ NULL
#' @name compute_score
#' @seealso [Traduction française][fr-compute_score()]
#' @export
compute_score.QR_matrix <- function(x,
score_pond = c(qs_residual_sa_on_sa = 30,
f_residual_sa_on_sa = 30,
qs_residual_sa_on_i = 20,
f_residual_sa_on_i = 20,
f_residual_td_on_sa = 30,
f_residual_td_on_i = 20,
oos_mean = 15,
oos_mse = 10,
residuals_independency = 15,
residuals_homoskedasticity = 5,
residuals_skewness = 5,
m7 = 5, q_m2 = 5),
modalities = c("Good", "Uncertain", "", "Bad", "Severe"),
normalize_score_value,
na.rm = FALSE,
n_contrib_score,
conditional_indicator,
...) {
compute_score.QR_matrix <- function(
x,
score_pond = c(qs_residual_sa_on_sa = 30,
f_residual_sa_on_sa = 30,
qs_residual_sa_on_i = 20,
f_residual_sa_on_i = 20,
f_residual_td_on_sa = 30,
f_residual_td_on_i = 20,
oos_mean = 15,
oos_mse = 10,
residuals_independency = 15,
residuals_homoskedasticity = 5,
residuals_skewness = 5,
m7 = 5, q_m2 = 5),
modalities = c("Good", "Uncertain", "", "Bad", "Severe"),
normalize_score_value,
na.rm = FALSE,
n_contrib_score,
conditional_indicator,
...) {
# score_formula_exp <- as.expression(substitute(score_formula))

QR_modalities <- x$modalities
Expand Down Expand Up @@ -484,8 +485,14 @@ extract_score.QR_matrix <- function(x, format_output = c("data.frame", "vector")
return(res)
}
#' @export
extract_score.mQR_matrix <- function(x, format_output = c("data.frame", "vector"), weighted_score = FALSE) {
return(lapply(x, extract_score, format_output = format_output, weighted_score = weighted_score))
extract_score.mQR_matrix <- function(
x,
format_output = c("data.frame", "vector"),
weighted_score = FALSE) {
return(lapply(X = x,
FUN = extract_score,
format_output = format_output,
weighted_score = weighted_score))
}


Expand Down Expand Up @@ -797,23 +804,25 @@ NULL
#' @family var QR_matrix manipulation
#' @seealso [Traduction française][fr-recode_indicator_num()]
#' @export
recode_indicator_num <- function(x,
variable_name,
breaks = c(0, .01, .05, .1, 1),
labels = c("Good", "Uncertain", "Bad", "Severe"),
...) {
recode_indicator_num <- function(
x,
variable_name,
breaks = c(0, .01, .05, .1, 1),
labels = c("Good", "Uncertain", "Bad", "Severe"),
...) {
UseMethod("recode_indicator_num", x)
}
#' @export
recode_indicator_num.default <- function(x, variable_name, breaks, labels, ...) {
stop("This function requires a QR_matrix or mQR_matrix object")
}
#' @export
recode_indicator_num.QR_matrix <- function(x,
variable_name,
breaks = c(0, .01, .05, .1, 1),
labels = c("Good", "Uncertain", "Bad", "Severe"),
...) {
recode_indicator_num.QR_matrix <- function(
x,
variable_name,
breaks = c(0, .01, .05, .1, 1),
labels = c("Good", "Uncertain", "Bad", "Severe"),
...) {
modalities <- x$modalities
values <- x$values
for (var in variable_name) {
Expand All @@ -831,15 +840,13 @@ recode_indicator_num.QR_matrix <- function(x,
return(x)
}
#' @export
recode_indicator_num.mQR_matrix <- function(x,
variable_name,
breaks = c(0, .01, .05, .1, 1),
labels = c("Good", "Uncertain", "Bad", "Severe"),
...) {
return(mQR_matrix(lapply(x,
recode_indicator_num,
variable_name = variable_name,
breaks = breaks,
labels = labels,
...)))
recode_indicator_num.mQR_matrix <- function(
x,
variable_name,
breaks = c(0, .01, .05, .1, 1),
labels = c("Good", "Uncertain", "Bad", "Severe"),
...) {
return(mQR_matrix(lapply(
X = x, FUN = recode_indicator_num,
variable_name = variable_name, breaks = breaks, labels = labels, ...)))
}
2 changes: 1 addition & 1 deletion R/extractQR.R
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ extractNormalityTests <- function(demetra_m) {
if (length(tests_possibles) != 3)
stop("At least one test is missing, among: skewness, kurtosis, lb2")

if (length(grep("^X\\.(\\d) {1,}$",
if (length(grep("^X\\.(\\d){1,}$",
colnames(demetra_m)[rep(tests_possibles, each = 2) + rep(1:2, 3)])) != 6)
stop("Re-compute the cruncher export with the options: residuals.skewness:3, residuals.kurtosis:3 and residuals.lb2:3")

Expand Down
52 changes: 42 additions & 10 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,52 @@ knitr::opts_chunk$set(
)
```

# JDCruncheR
# `JDCruncheR`

The primary objective of the JDCruncheR package is to provide a quick and easy access to the JDemetra+ cruncher (JWSACruncher) from R. The cruncher is a tool to update a JDemetra+ workspace, without having to open the software itself.
The latest version can be downloaded here: <https://github.com/jdemetra/jwsacruncher/releases>. Fore more information, please refer to the wiki page: <https://github.com/jdemetra/jwsacruncher/wiki>.
[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/JDCruncheR)](https://cran.r-project.org/package=JDCruncheR)

With JDCruncheR, you can also generate a *quality report* based on the cruncher output. This report is a summary of the seasonal adjustment diagnostics. It can be used to spot the most problematic series which will require a finer analysis. This is most useful when dealing with a great number of series, which renders impossible the examination of every diagnostic for every series in a reasonable time.
## Français 🇫🇷

There are two ways to install the JDCruncheR package:
### Présentation

- using the devtools package:
```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("InseeFr/JDCruncheR", build_vignettes = TRUE)
Le but premier du package `JDCruncheR` est de fournir un accès rapide et facile au cruncher (`JWSACruncher`) depuis R. Le cruncher est un outil de mise à jour des workspaces de JDemetra+ sans avoir à ouvrir la GUI (Graphical User Interface). La dernière version peut être téléchargée ici : https://github.com/jdemetra/jwsacruncher/releases. Pour plus d'information, vous pouvez visiter la page [wiki](https://github.com/jdemetra/jwsacruncher/wiki).

Avec `JDCruncheR`, vous pouvez aussi générer des *bilans qualité* utilisant l'output du cruncher. Ce bilan est un résumé des diagnostiques de la désaisonnalisation. Il peut être utilisé pour repérer les séries les plus problématiques qui nécessitent une analyse plus fine. Cela est très utile lorsqu'on a beaucoup de séries à désaisonnaliser.

### Installation

Il y a 2 méthodes d'installation du package `JDCruncheR` :

- utiliser le package `remotes` :

``` r
# install.packages("remotes")
remotes::install_github("InseeFr/JDCruncheR", build_vignettes = TRUE)
```

- depuis le dossier compressé **.zip** ou **.tar.gz**, qui peuvent être trouvés ici : https://github.com/InseeFr/JDCruncheR/releases. Pour plus d'informations sur l'installation et la configuration du package `JDCruncheR`, vous pouvez visiter la page [wiki](https://github.com/jdemetra/jwsacruncher/wiki)

Pour une description plus complète des packages R pour JDemetra+ voir le document de travail Insee [Les packages R pour JDemetra+ : une aide à la désaisonnalisation](https://www.insee.fr/fr/statistiques/5019786)

## English 🇬🇧

### Overview

The primary objective of the `JDCruncheR` package is to provide a quick and easy access to the JDemetra+ cruncher (`JWSACruncher`) from R. The cruncher is a tool for updating JDemetra+ workspaces, without having to open the graphical user interface. The latest version can be downloaded here: <https://github.com/jdemetra/jwsacruncher/releases>. For more information, please refer to the [wiki page](https://github.com/jdemetra/jwsacruncher/wiki).

With `JDCruncheR`, you can also generate a *quality report* based on the cruncher's output. This report is a formatted summary of the seasonal adjustment process main diagnostics and parameters. It can be used to spot the most problematic series which will require a finer analysis. This is most useful when dealing with a large number of series.

### Installation

There are two ways to install the `JDCruncheR` package:

- using the `remotes` package:

``` r
# install.packages("remotes")
remotes::install_github("InseeFr/JDCruncheR", build_vignettes = TRUE)
```
- from the **.zip** or **.tar.gz** file, that can both be found here: <https://github.com/InseeFr/JDCruncheR/releases>. For more info on the package installation and the cruncher configuration, please refer to the [wiki](https://github.com/InseeFr/JDCruncheR/wiki).

- from the **.zip** or **.tar.gz** file, that can both be found here: <https://github.com/InseeFr/JDCruncheR/releases>.

For a more comprehensive description of the R packages for JDemetra+ check the Insee working paper [R Tools for JDemetra+: Seasonal adjustment made easier](https://www.insee.fr/en/statistiques/5019812)
60 changes: 40 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,48 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->

# `JDCruncheR`

[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/JDCruncheR)](https://cran.r-project.org/package=JDCruncheR)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/JDCruncheR)](https://cran.r-project.org/package=JDCruncheR)

## Français 🇫🇷

### Présentation

Le but premier du package `JDCruncheR` est de fournir un accès rapide et facile au cruncher (`JWSACruncher`) depuis R. Le cruncher est un outil de mise à jour des workspaces de JDemetra+ sans avoir à ouvrir la GUI (Graphical User Interface). La dernière version peut être téléchargée ici : https://github.com/jdemetra/jwsacruncher/releases. Pour plus d'information, vous pouvez visiter la page [wiki](https://github.com/jdemetra/jwsacruncher/wiki).
Le but premier du package `JDCruncheR` est de fournir un accès rapide et
facile au cruncher (`JWSACruncher`) depuis R. Le cruncher est un outil
de mise à jour des workspaces de JDemetra+ sans avoir à ouvrir la GUI
(Graphical User Interface). La dernière version peut être téléchargée
ici : <https://github.com/jdemetra/jwsacruncher/releases>. Pour plus
d’information, vous pouvez visiter la page
[wiki](https://github.com/jdemetra/jwsacruncher/wiki).

Avec `JDCruncheR`, vous pouvez aussi générer des *bilans qualité* utilisant l'output du cruncher. Ce bilan est un résumé des diagnostiques de la désaisonnalisation. Il peut être utilisé pour repérer les séries les plus problématiques qui nécessitent une analyse plus fine. Cela est très utile lorsqu'on a beaucoup de séries à désaisonnaliser.
Avec `JDCruncheR`, vous pouvez aussi générer des *bilans qualité*
utilisant l’output du cruncher. Ce bilan est un résumé des diagnostiques
de la désaisonnalisation. Il peut être utilisé pour repérer les séries
les plus problématiques qui nécessitent une analyse plus fine. Cela est
très utile lorsqu’on a beaucoup de séries à désaisonnaliser.

### Installation

Il y a 2 méthodes d'installation du package `JDCruncheR` :
Il y a 2 méthodes dinstallation du package `JDCruncheR` :

- utiliser le package `remotes` :

``` r
# install.packages("remotes")
remotes::install_github("InseeFr/JDCruncheR", build_vignettes = TRUE)
```

- depuis le dossier compressé **.zip** ou **.tar.gz**, qui peuvent être trouvés ici : https://github.com/InseeFr/JDCruncheR/releases. Pour plus d'informations sur l'installation et la configuration du package `JDCruncheR`, vous pouvez visiter la page [wiki](https://github.com/jdemetra/jwsacruncher/wiki)
- depuis le dossier compressé **.zip** ou **.tar.gz**, qui peuvent être
trouvés ici : <https://github.com/InseeFr/JDCruncheR/releases>. Pour
plus d’informations sur l’installation et la configuration du package
`JDCruncheR`, vous pouvez visiter la page
[wiki](https://github.com/jdemetra/jwsacruncher/wiki)

Pour une description plus complète des packages R pour JDemetra+ voir le document de travail Insee [Les packages R pour JDemetra+ : une aide à la désaisonnalisation](https://www.insee.fr/fr/statistiques/5019786)
Pour une description plus complète des packages R pour JDemetra+ voir le
document de travail Insee [Les packages R pour JDemetra+ : une aide à la
désaisonnalisation](https://www.insee.fr/fr/statistiques/5019786)

## English 🇬🇧

Expand All @@ -33,29 +51,31 @@ Pour une description plus complète des packages R pour JDemetra+ voir le docume
The primary objective of the `JDCruncheR` package is to provide a quick
and easy access to the JDemetra+ cruncher (`JWSACruncher`) from R. The
cruncher is a tool for updating JDemetra+ workspaces, without having to
open the graphical user interface. The latest version can be downloaded here:
<https://github.com/jdemetra/jwsacruncher/releases>. For more
information, please refer to the [wiki page](https://github.com/jdemetra/jwsacruncher/wiki).
open the graphical user interface. The latest version can be downloaded
here: <https://github.com/jdemetra/jwsacruncher/releases>. For more
information, please refer to the [wiki
page](https://github.com/jdemetra/jwsacruncher/wiki).

With `JDCruncheR`, you can also generate a *quality report* based on the
cruncher's output. This report is a formatted summary of the seasonal adjustment process
main diagnostics and parameters. It can be used to spot the most problematic series which
will require a finer analysis. This is most useful when dealing with a large number of series.
cruncher’s output. This report is a formatted summary of the seasonal
adjustment process main diagnostics and parameters. It can be used to
spot the most problematic series which will require a finer analysis.
This is most useful when dealing with a large number of series.

### Installation

There are two ways to install the `JDCruncheR` package:

- using the `remotes` package:

``` r
# install.packages("remotes")
remotes::install_github("InseeFr/JDCruncheR", build_vignettes = TRUE)
```

- from the **.zip** or **.tar.gz** file, that can both be found here:
<https://github.com/InseeFr/JDCruncheR/releases>. For more info on
the package installation and the cruncher configuration, please
refer to the [wiki](https://github.com/InseeFr/JDCruncheR/wiki).
<https://github.com/InseeFr/JDCruncheR/releases>.

For a more comprehensive description of the R packages for JDemetra+ check the Insee working paper [R Tools for JDemetra+: Seasonal adjustment made easier](https://www.insee.fr/en/statistiques/5019812)
For a more comprehensive description of the R packages for JDemetra+
check the Insee working paper [R Tools for JDemetra+: Seasonal
adjustment made easier](https://www.insee.fr/en/statistiques/5019812)

0 comments on commit 5f31ff8

Please sign in to comment.