diff --git a/DESCRIPTION b/DESCRIPTION index ccd1e30..0665e1a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -74,4 +74,4 @@ URL: https://inseefrlab.github.io/rtauargus, BugReports: https://github.com/inseefrlab/rtauargus/issues Roxygen: list(markdown = TRUE) StagedInstall: no -Config/roxygen2/version: 8.1.0 +Config/roxygen2/version: 8.1.1 diff --git a/NEWS.md b/NEWS.md index ffac3b1..d0a1238 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,9 @@ title: ‘rtauargus’ package / Package ‘rtauargus’ subtitle: History of changes / Historique des modifications output: rmarkdown::html_vignette +editor_options: + markdown: + wrap: 72 --- ## rtauargus 1.3.6 @@ -20,10 +23,12 @@ Fix several bugs in the v1.3.5: [08/2026] -- Improved management of links between indicators, particularly by handling the non-nested hierarchies resulting from the equations. +- Improved management of links between indicators, particularly by + handling the non-nested hierarchies resulting from the equations. -- Feature added to `tab_rtauargus` and `tab_multi_manager()` letting user get a summary of the suppression process. -Use the `summary_secret = TRUE` to activate it. +- Feature added to `tab_rtauargus` and `tab_multi_manager()` letting + user get a summary of the suppression process. Use the + `summary_secret = TRUE` to activate it. ## rtauargus 1.3.4 @@ -31,34 +36,33 @@ Use the `summary_secret = TRUE` to activate it. Improving the reporting of common cells in `tab_multi_manager()`. - ## rtauargus 1.3.3 [02/2026] -* Bug fixed +- Bug fixed -Importing some files built by $\tau$-ARGUS produced errors -because of encoding. From French users, this bug appeared during -december and february months ("Décembre", "Février"). +Importing some files built by $\tau$-ARGUS produced errors because of +encoding. From French users, this bug appeared during december and +february months ("Décembre", "Février"). -The fix consists in blocking logbook importation during the process while this -kind of error is produced. It has no effect on the suppression process, only -on the information displayed in the console. +The fix consists in blocking logbook importation during the process +while this kind of error is produced. It has no effect on the +suppression process, only on the information displayed in the console. ## rtauargus 1.3.2 [01/2026] -* Add automatic analysis of links between indicators - -This version adds a new parameter to `analyse_metadata()` : `df_eq_indicator`. -This parameter allows the user to specify links between indicators. +- Add automatic analysis of links between indicators -An article presenting this new feature was presented at the JMS conference -in 2025 (paper in French): -https://journees-methodologie-statistique.insee.net/analyse-automatique-des-metadonnees-pour-la-protection-des-donnees-tabulees/#presentation +This version adds a new parameter to `analyse_metadata()` : +`df_eq_indicator`. This parameter allows the user to specify links +between indicators. +An article presenting this new feature was presented at the JMS +conference in 2025 (paper in French): + ## rtauargus 1.3.1 @@ -66,178 +70,219 @@ https://journees-methodologie-statistique.insee.net/analyse-automatique-des-meta Bug fixed: -Previously, a list of 1-dimensional tables with no common cells hit by -secondary suppression would have produced an error during the call -of `tab_multi_manager()`. +Previously, a list of 1-dimensional tables with no common cells hit by +secondary suppression would have produced an error during the call of +`tab_multi_manager()`. + +## rtauargus 1.3.0 + +[06/2025] + +The new version comes with new functions to help the metadata analysis : + +- `analyse_metadata()` that automatically analyses metadata + +> The input is a dataframe describing all the tables that will be +> published. The function returns an other dataframe that describes the +> tables to protect and indicates which tables should be treated +> together (i.e. using `tab_multi_manager()`). + +- `format_template()` (Eurostat template) + +> The input is an extract of the Eurostat template (only the relevant +> columns). It goes through all the cells described by the template and +> returns the metadata of the underlying tables. This metadata is stored +> in a dataframe in the right format to be the input of the +> `analyse_metadata()` function. + +> A poster presenting those functions has been presented at the NTTS +> conference in 2025, it is available here: +> [https://github.com/InseeFrLab/automatic_analysis_poster_NTTS2025](). ## rtauargus 1.2.999-dev [02/2025] -* Development of the function `analyse_metadata()` that automatically analyses metadata +- Development of the function `analyse_metadata()` that automatically + analyses metadata -> The input is a dataframe describing all the tables that will be published. -The function returns an other dataframe that describes the tables to protect and -indicates which tables should be treated together (i.e. using `tab_multi_manager()`). +> The input is a dataframe describing all the tables that will be +> published. The function returns an other dataframe that describes the +> tables to protect and indicates which tables should be treated +> together (i.e. using `tab_multi_manager()`). -* Development of the function `template_formatted()` (Eurostat template) +- Development of the function `template_formatted()` (Eurostat template) -> The input is an extract of the Eurostat template (only the relevant columns). -It goes through all the cells described by the template and returns the metadata of -the underlying tables. This metadata is stored in a dataframe in the right format -to be the input of the `analyse_metadata()` function. +> The input is an extract of the Eurostat template (only the relevant +> columns). It goes through all the cells described by the template and +> returns the metadata of the underlying tables. This metadata is stored +> in a dataframe in the right format to be the input of the +> `analyse_metadata()` function. -> A poster presenting those functions will be presented at the NTTS2025, it is -available here: "https://github.com/InseeFrLab/automatic_analysis_poster_NTTS2025". +> A poster presenting those functions will be presented at the NTTS2025, +> it is available here: +> "". ## rtauargus 1.2.0 [01/2024] -* Implementation of a method to tackle some tables of 4/5 dimensions. +- Implementation of a method to tackle some tables of 4/5 dimensions. -> The method is quickly explained and its use is shown in a specific vignette (french). -> A paper explaining more deeply the idea and the modus operandi is available -here: "https://github.com/InseeFrLab/dims_reduction_tables_workshop_20231215". +> The method is quickly explained and its use is shown in a specific +> vignette (french). A paper explaining more deeply the idea and the +> modus operandi is available here: +> "". -* Implementation of the function `tabulate_micro_data()` to compute tabular data from -a microdata file. +- Implementation of the function `tabulate_micro_data()` to compute + tabular data from a microdata file. -> The function can create frequency and magnitude tabular data with hierarchical variables. -The tabular data computed contains the information to compute primary secret -according to frequency rule and (1,k)-dominance rule. +> The function can create frequency and magnitude tabular data with +> hierarchical variables. The tabular data computed contains the +> information to compute primary secret according to frequency rule and +> (1,k)-dominance rule. -* Resolution of a malfunction while dealing with costs. +- Resolution of a malfunction while dealing with costs. -* **rtauargus()** function has been renamed more properly as **micro_rtauargus()**. -Its arguments and its behaviour remain the same. +- **rtauargus()** function has been renamed more properly as + **micro_rtauargus()**. Its arguments and its behaviour remain the + same. ## rtauargus 1.1.2 [01/02/2023] -* Improvement in handling Interval Protection Level while using **tab_multi_manager()**: +- Improvement in handling Interval Protection Level while using + **tab_multi_manager()**: -> The IP levels are now set automatically into the apriori files for actual Primary Suppressed Cells -and only them. This ensures IP to be applied only for the actual primary secret and limits the -propagation of suppressions due to IP manipulation. In some very particular cases, this can lead to -significantly reduce the suppressions. +> The IP levels are now set automatically into the apriori files for +> actual Primary Suppressed Cells and only them. This ensures IP to be +> applied only for the actual primary secret and limits the propagation +> of suppressions due to IP manipulation. In some very particular cases, +> this can lead to significantly reduce the suppressions. ## rtauargus 1.1.0 [01/10/2022] -* **tab_multi_manager()**: argument *alt_hrc* and *alt_totcode* to handle non-nested hierarchies. +- **tab_multi_manager()**: argument *alt_hrc* and *alt_totcode* to + handle non-nested hierarchies. ## rtauargus 1.0.0 [01/09/2022] -* English documentation -* **tab_multi_manager()**: function to protect several tables at once. -* **tab_arb()** : argument *value* is now called *response_var* as in the **tab_rda()** function. -* **tab_arb()** : argument *apriori* is now called *hst_filename* as in the **tab_rda()** function. -* **write_hrc2()** : new function to creat a hrc file from a correspondence table +- English documentation\ +- **tab_multi_manager()**: function to protect several tables at once.\ +- **tab_arb()** : argument *value* is now called *response_var* as in + the **tab_rda()** function.\ +- **tab_arb()** : argument *apriori* is now called *hst_filename* as in + the **tab_rda()** function.\ +- **write_hrc2()** : new function to creat a hrc file from a + correspondence table ## rtauargus 0.5.0 [18/04/2022] -* Ajout de fonctions pour gérer le secret directement sur des données tabulées. -Addition of functions to manage confidentiality directly on tabular data. +- Ajout de fonctions pour gérer le secret directement sur des données + tabulées.\ + Addition of functions to manage confidentiality directly on tabular + data. ## rtauargus 0.4.3 [13/10/2021] -* projet transféré dans le groupe `outilsconfidentialite` +- projet transféré dans le groupe `outilsconfidentialite` ## rtauargus 0.4.2 [17/12/2020] -* projet migré vers gitlab.insee.fr +- projet migré vers gitlab.insee.fr ## rtauargus 0.4.1 [18/10/2019] -* **rtauargus_plus()** : extension de la fonction `rtauargus` pour un grand - nombre de croisements (ayant tous les mêmes caractéristiques). Réduit le temps - d'exécution par rapport à la version "normale". +- **rtauargus_plus()** : extension de la fonction `rtauargus` pour un + grand nombre de croisements (ayant tous les mêmes caractéristiques). + Réduit le temps d'exécution par rapport à la version "normale". ## rtauargus 0.4.0 [04/09/2019] -* **rtauargus()** peut désormais prendre en entrée un couple de fichiers asc et - rda (au lieu d'un data.frame). Permet de lancer un traitement dans le cas - où ces fichiers texte de microdonnées existent déjà. -* **run_arb()** : - - nouveau nom de run_tauargus (nom plus explicite, - principalement pour éviter la confusion avec la fonction _rtauargus_). - L'ancien nom reste pour l'instant utilisable : un message avertit du - changement. Il sera remplacé par un message d'erreur dans une prochaine - version. - - vérifications préalables à l'exécution de τ-Argus : - * existence du logiciel sur le poste ; - * existence des fichiers asc et rda ; - * présence des variables à utiliser (croisements, variable de réponse, - ...) dans les métadonnées (fichier rda) ; - * existence des dossiers où vont être écrits les résultats. Si absents, - possibilité de les créer automatiquement (paramètre `missing_dir` avec - option associée `rtauargus.missing_dir`). -* **import()** : si des fichiers _apriori_ ont été utilisés, stockage du nom de - ces fichiers dans les métadonnées (attributs) de l'objet R créé -* améliorations de la documentation (rubriques d'aide et vignette) +- **rtauargus()** peut désormais prendre en entrée un couple de fichiers + asc et rda (au lieu d'un data.frame). Permet de lancer un traitement + dans le cas où ces fichiers texte de microdonnées existent déjà. +- **run_arb()** : + - nouveau nom de run_tauargus (nom plus + explicite, principalement pour éviter la confusion avec la fonction + *rtauargus*). L'ancien nom reste pour l'instant utilisable : un + message avertit du changement. Il sera remplacé par un message + d'erreur dans une prochaine version. + - vérifications préalables à l'exécution de τ-Argus : + - existence du logiciel sur le poste ; + - existence des fichiers asc et rda ; + - présence des variables à utiliser (croisements, variable de + réponse, ...) dans les métadonnées (fichier rda) ; + - existence des dossiers où vont être écrits les résultats. Si + absents, possibilité de les créer automatiquement (paramètre + `missing_dir` avec option associée `rtauargus.missing_dir`). +- **import()** : si des fichiers *apriori* ont été utilisés, stockage du + nom de ces fichiers dans les métadonnées (attributs) de l'objet R créé +- améliorations de la documentation (rubriques d'aide et vignette) ## rtauargus 0.3.1 [11/07/2019] -* informe de l'absence de tauargus.exe au chargement du package -* diverses améliorations de la documentation (rubriques d'aide et vignette) -* utilise valeurs par défaut des options en cas d'effacement accidentel par - l'utilisateur +- informe de l'absence de tauargus.exe au chargement du package +- diverses améliorations de la documentation (rubriques d'aide et + vignette) +- utilise valeurs par défaut des options en cas d'effacement accidentel + par l'utilisateur ## rtauargus 0.3.0 [29/03/2019] -* **micro_arb()** : - - ajoute paramètre apriori (fichiers hst) - - conserve les noms de tabulations en sortie si précisés dans - `explanatory_vars` -* vérification plus rigoureuse de certains paramètres +- **micro_arb()** : + - ajoute paramètre apriori (fichiers hst) + - conserve les noms de tabulations en sortie si précisés dans + `explanatory_vars` +- vérification plus rigoureuse de certains paramètres ## rtauargus 0.2.1 [03/12/2018] -* **write_hrc()** : prise en compte de davantage de cas particuliers -* améliore vignette +- **write_hrc()** : prise en compte de davantage de cas particuliers +- améliore vignette ## rtauargus 0.2.0 [14/08/2018] -* **micro_arb()** : - - implémente tableaux liés (paramètre **linked**) - - corrige extensions de fichiers pour `"5"` (.tab) et `"6"` (.jj) - - corrige bug quand un seul paramètre à suppress, par exemple `MOD(1)` -* **write_hrc()** : nouvelle fonction créant un fichier .hrc à partir de - variables hiérarchiques présentes dans les microdonnées -* **micro_asc_rda()** : - - implémente paramètres **missing**, **totcode** et **codelist** - - simplifie syntaxe pour paramètre **hrc** (cohérente avec nouveaux - paramètres) - - nouveau paramètre **hierleadstring** (valeur par défaut dans l'option de - package **rtauargus.hierleadstring**) -* efface les options du package à son déchargement -* corrections diverses documentation +- **micro_arb()** : + - implémente tableaux liés (paramètre **linked**) + - corrige extensions de fichiers pour `"5"` (.tab) et `"6"` (.jj) + - corrige bug quand un seul paramètre à suppress, par exemple `MOD(1)` +- **write_hrc()** : nouvelle fonction créant un fichier .hrc à partir de + variables hiérarchiques présentes dans les microdonnées +- **micro_asc_rda()** : + - implémente paramètres **missing**, **totcode** et **codelist** + - simplifie syntaxe pour paramètre **hrc** (cohérente avec nouveaux + paramètres) + - nouveau paramètre **hierleadstring** (valeur par défaut dans + l'option de package **rtauargus.hierleadstring**) +- efface les options du package à son déchargement +- corrections diverses documentation ## rtauargus 0.1.0 [01/08/2018] -* Première version stable. +- Première version stable. diff --git a/R/analyse_metadata.R b/R/analyse_metadata.R index d4dd6de..bec471b 100644 --- a/R/analyse_metadata.R +++ b/R/analyse_metadata.R @@ -6,7 +6,7 @@ #' creating a structured output for further processing. #' #' @param df_metadata A dataframe containing metadata in wide format. -#' @param df_eq_indicator A datadframe containing the indicators equations if needed. +#' @param df_eq_indicator A dataframe containing the indicators equations if needed. #' @param verbose Logical. If `TRUE`, returns a detailed list of intermediate results #' from each processing step. If `FALSE`, returns only the cluster assignments. Defaults to `FALSE`. #' diff --git a/R/hrc.R b/R/hrc.R index 7af43c5..e09fd60 100644 --- a/R/hrc.R +++ b/R/hrc.R @@ -63,7 +63,7 @@ #' (nom et emplacement du fichier hrc produit. Si non renseigné, un fichier temporaire.) #' @param fill_na fill in any missing values, using an other variable : #' \itemize{ -#' \item{`"up"` (default) : hierarchical variable of the level level +#' \item{`"up"` (default) : hierarchical variable of the level #' immediately above} #' \item{`"down"` : hierarchical variable of the level immediately #' lower} diff --git a/R/micro_arb.R b/R/micro_arb.R index 49cd32e..26d4100 100644 --- a/R/micro_arb.R +++ b/R/micro_arb.R @@ -150,7 +150,7 @@ apriori_batch <- function(ntab, hst_names, sep = ',', ignore_err = 0 , exp_triv #' protection problems. #' #' See more details in `vignette("rtauargus")` or in -#' `vignette("protect_multi_tables)`. +#' `vignette("protect_multi_tables")`. #' #' Creates a batch file for microdata, executable by Tau-Argus in #' command line. \cr @@ -196,7 +196,7 @@ apriori_batch <- function(ntab, hst_names, sep = ',', ignore_err = 0 , exp_triv #' @section Table identifiers: #' If the list `explanatory_vars` has names, these will be #' used in the batch to give an identifier to the table, in the form of -#' of a comment line (`// "..."`). They will be +#' a comment line (`// "..."`). They will be #' reused by the `import` function to name the R format arrays #' tables in output. #' @@ -289,7 +289,7 @@ apriori_batch <- function(ntab, hst_names, sep = ',', ignore_err = 0 , exp_triv #' renuméroté automatiquement (voir la section 'Syntax').) #' @param linked to process the secondary secret jointly on all #' tabs. Only one delete command is allowed in this case (applied to all -#' all tables). \cr +#' tables). \cr #' (pour traiter le secret secondaire conjointement sur toutes les #' tabulations. Une seule commande suppress autorisée dans ce cas (appliquée à #' tous les tableaux).) diff --git a/R/micro_asc_rda.R b/R/micro_asc_rda.R index edbea0b..5428af3 100644 --- a/R/micro_asc_rda.R +++ b/R/micro_asc_rda.R @@ -67,7 +67,7 @@ write_rda <- function(info_vars) { #' protection problems. #' #' See more details in `vignette("rtauargus")` or in -#' `vignette("protect_multi_tables)`. +#' `vignette("protect_multi_tables")`. #' #' Creates a fixed length text file (asc) and a metadata file #' (rda) from microdata and additional information. \cr @@ -89,11 +89,11 @@ write_rda <- function(info_vars) { #' @param holding_var nom de la variable de holding. #' (name of the holding variable.) \cr #' @param decimals minimum number of decimals to display (see section 'Number of -#' of decimals'). +#' decimals'). #' (nombre minimal de décimales à afficher (voir section 'Number of #' of decimals').) #' @param hrc information about the hierarchical variables (see section -#' section 'Hierarchical variables'). \cr +#' 'Hierarchical variables'). \cr #' (informations sur les variables hiérarchiques (voir section #' 'Hierarchical variables').) #' @param hierleadstring character which, repeated n times, indicates that the value is @@ -120,8 +120,8 @@ write_rda <- function(info_vars) { #' #' @return #' Returns the names of the asc and rda files as a list (invisibly). -#' invisibly). Empty columns (filled with `NA` or empty strings) are not -#' strings) will not be exported to the asc file. A +#' Empty columns (filled with `NA` or empty strings) will not be +#' exported to the asc file. A #' warning message will list the affected columns. \cr #' (Renvoie les noms des fichiers asc et rda sous forme de liste (de #' manière invisible). Les colonnes vides (remplies de `NA` ou de chaînes @@ -136,7 +136,7 @@ write_rda <- function(info_vars) { #' #' The names of the elements of the vector give the variable concerned, the elements #' of the vector give the value of the parameter for Tau-Argus. An unnamed element -#' element will be the default value, which will be assigned to all +#' will be the default value, which will be assigned to all #' variables that can take this parameter. #' #' For example : @@ -173,7 +173,7 @@ write_rda <- function(info_vars) { #' hierarchical variables. #' #' To define a hierarchy based on the positions of characters -#' (**hierierlevels**), pass a sequence of integers separated by +#' (**hierlevels**), pass a sequence of integers separated by #' spaces. #' #' *Example :* `c(CODECOM = "2 3 0 0 0")` @@ -182,7 +182,7 @@ write_rda <- function(info_vars) { #' (**hiercodelist**), the function expects the location of this file (and #' a possible `hiercodelist` if it differs from the default option of the #' package). In this case, you can write explicitly the path to an existing file -#' file (`c(A38 = "a38.hrc")`), but also make a call to +#' (`c(A38 = "a38.hrc")`), but also make a call to #' `write_hrc()` which will generate an hrc file from microdata. #' #' *Example :* `c(A38 = write_hrc(microdata, c("A38", "A21", "A10")))` @@ -238,7 +238,7 @@ write_rda <- function(info_vars) { #' #' @section Number of decimals: #' -#' The parameter `decimals` indicates the minimum number of decimals to be +#' The parameter `decimals` indicates the minimum number of decimals to #' appear in the output file (whatever the number of decimals #' actually present in `microdata`). It applies to all #' real variables (double) but not to integer variables (integer). For diff --git a/R/micro_rtauargus.R b/R/micro_rtauargus.R index 00ace87..04309fb 100644 --- a/R/micro_rtauargus.R +++ b/R/micro_rtauargus.R @@ -9,7 +9,7 @@ #' protection problems. #' #' See more details in `vignette("rtauargus")` or in -#' `vignette("protect_multi_tables)`. +#' `vignette("protect_multi_tables")`. #' #' Protects tables built from microdata and specifications of the crossings. #' The function allows to perform the complete process, namely the creation of @@ -32,7 +32,7 @@ #' Intermediate files without a name entered (`asc_filename`...) #' will be created in a temporary folder, with randomly generated names. #' This mechanism allows the user to abstract from the preparation of -#' preparation of the data and to maintain the entire chain of +#' the data and to maintain the entire chain of #' processing in R. \cr #' #' (La fonction exécute séquentiellement les fonctions : \itemize{ @@ -64,7 +64,7 @@ #' @inheritSection micro_arb Syntax #' #' @section Microdata already as text files: -#' To use existing asc and rda files already existing, it is possible to +#' To use existing asc and rda files, it is possible to #' provide, instead of the data.frame, a character vector indicating #' the path of these files. The first element of this vector is the asc file, #' the second element the rda file. The rda file can be omitted if it has the diff --git a/R/multitable.R b/R/multitable.R index 53ec001..498ba8e 100644 --- a/R/multitable.R +++ b/R/multitable.R @@ -11,7 +11,7 @@ journal_add_line <- function(journal,...){ #' @inheritParams tab_rtauargus #' @param list_tables named list of `data.frame` or `data.table` representing the tables to protect #' @param list_explanatory_vars named list of character vectors of explanatory -#' variables of each table mentionned in list_tables. Names of the list are the same as of the list of tables. +#' variables of each table mentioned in list_tables. Names of the list are the same as of the list of tables. #' @param alt_hrc named list for alternative hierarchies (useful for non nested-hierarchies) #' @param alt_totcode named list for alternative codes #' @param ip_start integer: Interval protection level to apply at first treatment of each table diff --git a/R/options.R b/R/options.R index b52082a..098f51e 100644 --- a/R/options.R +++ b/R/options.R @@ -92,7 +92,7 @@ df_op.rtauargus <- function(html = FALSE) { #' user.* #' #' On loading the package, all the rtauargus options, that are not already -#' been set by the user, are set with their default values (see table below). +#' set by the user, are set with their default values (see table below). #' The already defined options keep the values set by the user. #' #' The options can be set during a session with the following instruction diff --git a/R/rtauargus_plus.R b/R/rtauargus_plus.R index 2deaf78..657bee5 100644 --- a/R/rtauargus_plus.R +++ b/R/rtauargus_plus.R @@ -7,7 +7,7 @@ #' #' In interactive mode, Tau-Argus can process up to 10 tabs #' simultaneously for the same microdata set. In batch mode, a larger number of -#' of crossings can be specified. However, doing so +#' crossings can be specified. However, doing so #' can be particularly time consuming, as Tau-Argus takes a lot of time #' to read large text files of microdata. #' @@ -15,7 +15,7 @@ #' splits the list of tabs into groups of size `grp_size` and #' makes a call to `micro_rtauargus()` for each group. It writes an #' asc file restricted to the only variables actually used within a -#' of a group. +#' group. #' #' The results are then aggregated into a single list, as if Tau-Argus #' had been called only once. @@ -23,7 +23,7 @@ #' Modifying `grp_size` will not change the result, only the time #' execution time. A value around 5 (default) seems to be a good compromise #' between reading too large asc files and calling Tau-Argus too often. -#' Tau-Argus too much. It can be adjusted according to the number of +#' It can be adjusted according to the number of #' common variables within each tab group. # #' (En mode interactif, Tau-Argus peut traiter jusqu'à 10 tabulations @@ -52,7 +52,7 @@ #' #' In return for the speed of execution, the crossings must have the #' same characteristics (same primary secret rules, same secondary secret method, -#' same secondary secret, same weighting variable, etc.). The parameters +#' same weighting variable, etc.). The parameters #' `safety_rules`, `supress`, ..., must therefore contain a #' unique value. #' diff --git a/R/run_arb.R b/R/run_arb.R index 9c8d62e..4eda058 100644 --- a/R/run_arb.R +++ b/R/run_arb.R @@ -183,14 +183,14 @@ unquote <- function(s) sub("^[\"'](.+)[\"']$", "\\1", s) #' therefore requires the software to be accessible from the workstation. #' #' The location of the TauArgus.exe program is defined globally when the -#' loading the package. In fact, the argument `tauargus_exe` will not +#' loading the package. In fact, the argument `tauargus_exe` will #' normally not have to be specified (except to override the global option the #' time of the execution of the function). #' #' Checks are made before the actual launching of Tau-Argus: #' existence of the software on the computer, of the asc and rda files, of the folders where #' write the results, the variables to be used (crossings, response variable) in the -#' response variable) in the metadata (rda file). \cr +#' metadata (rda file). \cr #' #' (Seul l’argument `arb_filename` est obligatoire, car toutes les #' informations nécessaires sont présentes dans ce fichier. diff --git a/R/tab_arb.R b/R/tab_arb.R index 59e1cdb..0a5dc25 100644 --- a/R/tab_arb.R +++ b/R/tab_arb.R @@ -87,7 +87,7 @@ tab_apriori_batch <- function(hst_names, sep, ignore_err = 0 , exp_triv = 0) { #' #' @section Syntaxe: #' -#' For tabular data, this function secures only one table at a time#' +#' For tabular data, this function secures only one table at a time. #' Unless specific details, use syntax from Tau-Argus manual \cr #' Sauf mention contraire, utiliser la syntaxe mentionnée dans la documentation #' de Tau-Argus. @@ -149,7 +149,7 @@ tab_apriori_batch <- function(hst_names, sep, ignore_err = 0 , exp_triv = 0) { #' Chaîne de caractères en syntaxe batch Tau-Argus. Si le secret primaire #' a été traité dans un fichier d'apriori : utiliser "MAN(10)") #' @param suppress -#' Algortihm for secondary suppression (Tau-Argus batch syntax), and the +#' Algorithm for secondary suppression (Tau-Argus batch syntax), and the #' parameters for it.\cr #' ( Algorithme de gestion du secret secondaire #' (syntaxe batch de Tau-Argus), ainsi que les potentiels paramètres associés) @@ -161,7 +161,7 @@ tab_apriori_batch <- function(hst_names, sep, ignore_err = 0 , exp_triv = 0) { #' (Format des fichiers en sortie (codification Tau-Argus). #' Valeur par défaut du package : `"2"` (csv for pivot-table). #' Pour le format SBS utiliser `"4"`) -#' @param output_options Additionnal parameter for the output, +#' @param output_options Additional parameter for the output, #' by default : \code{"AS+"} (print Status). To specify no options : `""`.\cr #' (Options supplémentaires des fichiers en sortie. Valeur #' par défaut du package : `"AS+"` (affichage du statut). Pour ne @@ -169,10 +169,10 @@ tab_apriori_batch <- function(hst_names, sep, ignore_err = 0 , exp_triv = 0) { #' @param gointeractive Boolean, if TRUE will open a Tau-Argus window and launch #' the batch in it (`FALSE` by default). \cr #' (Possibilité de lancer le batch depuis le menu de Tau-Argus -#' (`FALSE` par défaut).) +#' (`FALSE` par défaut). #' #' @return A list containing two elements : -#' the arb file name and the output name (usefull if the name is generated randomly) \cr +#' the arb file name and the output name (useful if the name is generated randomly) \cr #' (Une liste de deux éléments : le nom du fichier arb, le nom #' fichiers en sortie (utile pour récupérer les noms générés aléatoirement).) #' diff --git a/R/tab_rda.R b/R/tab_rda.R index 87d8792..6fdffce 100644 --- a/R/tab_rda.R +++ b/R/tab_rda.R @@ -146,7 +146,7 @@ write_rda_tab <- function(info_vars) { #' (Variable indiquant le secret primaire de type booléen: #' prend la valeur "TRUE" quand les cellules du tableau doivent être masquées #' par le secret primaire, "FALSE" sinon. Permet de créer un fichier d'apriori) -#' @param secret_var Nae of the boolean variable which specifies the secret, primary or not : +#' @param secret_var Name of the boolean variable which specifies the secret, primary or not : #' equal to "TRUE" if a cell is concerned by the secret,"FALSE" otherwise. #' will be exported in the apriori file. \cr #' (Variable indiquant le secret de type booléen: @@ -265,7 +265,7 @@ write_rda_tab <- function(info_vars) { #' ` "global"` pour toutes les variables catégorielles #' sauf `size` and `income`} qui se verront affecter #' le total : ` "total"` -#' Par defaut : ` "Total"` +#' Par défaut : ` "Total"` #' } #' #' @@ -297,7 +297,7 @@ write_rda_tab <- function(info_vars) { #' Les éléments du vecteur en paramètre doivent nommés (avec le nom de la variable), #' même s'il n'y a qu'un seul élément. #' -#'*Exemple :*`c(category="category.hrc")`) +#' *Exemple :* `c(category="category.hrc")` #' #' #' @section Number of decimals: diff --git a/R/tab_rtauargus.R b/R/tab_rtauargus.R index c1cda6c..7fc452a 100644 --- a/R/tab_rtauargus.R +++ b/R/tab_rtauargus.R @@ -9,7 +9,7 @@ #' #' @param files_name string used to name all the files needed to process. #' All files will have the same name, only their extension will be different. -#' @param dir_name string indicated the path of the directory in which to save +#' @param dir_name string indicating the path of the directory in which to save #' all the files (.rda, .hst, .txt, .arb, .csv) generated by the function. #' @param summary_secret If `TRUE`, a statistical summary of the suppression is provided along with the masked data. #' @param unif_labels boolean, if explanatory variables have to be standardized diff --git a/R/writehrc.R b/R/writehrc.R index 3ade366..d1545d1 100644 --- a/R/writehrc.R +++ b/R/writehrc.R @@ -67,7 +67,7 @@ vect_aro <- Vectorize(arobase, vectorize.args = c("string", "number")) #' Si TRUE, inverse l'ordre des colonnes. #' @param hier_lead_string character. (Single) character indicating the #' hierarchy depth in the .hrc file. By default, the value is set to the current -#' value mentionned in the package options (i.e. "@" at the package startup). +#' value mentioned in the package options (i.e. "@" at the package startup). #' \cr #' Caractère unique repérant le niveau de profondeur dans le .hrc #' @param adjust_unique_roots boolean. If TRUE (default) will add fictional roots to the @@ -83,13 +83,13 @@ vect_aro <- Vectorize(arobase, vectorize.args = c("string", "number")) #' character Si adjust_unique_roots est TRUE add_char est l'élément qui sera #' utilisé afin de créer des feuilles fictives, il faut être sur que cela #' ne crée pas de doublons dans la hiérarchie.La chaine de caractère sera -#' ajouté au début d'une feuille unique. Par defaut :"ZZZ" +#' ajouté au début d'une feuille unique. Par défaut : "ZZZ" #' @details Creates a .hrc hierarchy file adapted to tau-Argus from a #' correspondence table fully describing it. By default, lines are sorted #' alphabetically so as to regroup identical levels. #' #' Ecrit un fichier de hiérarchie .hrc lisible par tau-Argus à -#' partir d'une table de corrrespondance la décrivant complètement. Par défaut, +#' partir d'une table de correspondance la décrivant complètement. Par défaut, #' les lignes du tableau seront triées afin de regrouper les niveaux de #' hiérarchie identiques. #' diff --git a/man/analyse_metadata.Rd b/man/analyse_metadata.Rd index 216e9ef..9717665 100644 --- a/man/analyse_metadata.Rd +++ b/man/analyse_metadata.Rd @@ -9,7 +9,7 @@ analyse_metadata(df_metadata, df_eq_indicator = NULL, verbose = FALSE) \arguments{ \item{df_metadata}{A dataframe containing metadata in wide format.} -\item{df_eq_indicator}{A datadframe containing the indicators equations if needed.} +\item{df_eq_indicator}{A dataframe containing the indicators equations if needed.} \item{verbose}{Logical. If \code{TRUE}, returns a detailed list of intermediate results from each processing step. If \code{FALSE}, returns only the cluster assignments. Defaults to \code{FALSE}.} diff --git a/man/micro_arb.Rd b/man/micro_arb.Rd index 3b534be..fab4257 100644 --- a/man/micro_arb.Rd +++ b/man/micro_arb.Rd @@ -91,7 +91,7 @@ renuméroté automatiquement (voir la section 'Syntax').)} \item{linked}{to process the secondary secret jointly on all tabs. Only one delete command is allowed in this case (applied to all -all tables). \cr +tables). \cr (pour traiter le secret secondaire conjointement sur toutes les tabulations. Une seule commande suppress autorisée dans ce cas (appliquée à tous les tableaux).)} @@ -141,7 +141,7 @@ or \code{tab_multi_manager()}, which offer a lot more features for your protection problems. See more details in \code{vignette("rtauargus")} or in -\verb{vignette("protect_multi_tables)}. +\code{vignette("protect_multi_tables")}. Creates a batch file for microdata, executable by Tau-Argus in command line. \cr @@ -190,7 +190,7 @@ tabulation, en 2 pour la deuxième tabulation, etc.) If the list \code{explanatory_vars} has names, these will be used in the batch to give an identifier to the table, in the form of -of a comment line (\verb{// "..."}). They will be +a comment line (\verb{// "..."}). They will be reused by the \code{import} function to name the R format arrays tables in output. diff --git a/man/micro_asc_rda.Rd b/man/micro_asc_rda.Rd index 53ab01d..c69eedf 100644 --- a/man/micro_asc_rda.Rd +++ b/man/micro_asc_rda.Rd @@ -40,12 +40,12 @@ un fichier temporaire.)} (name of the holding variable.) \cr} \item{decimals}{minimum number of decimals to display (see section 'Number of -of decimals'). +decimals'). (nombre minimal de décimales à afficher (voir section 'Number of of decimals').)} \item{hrc}{information about the hierarchical variables (see section -section 'Hierarchical variables'). \cr +'Hierarchical variables'). \cr (informations sur les variables hiérarchiques (voir section 'Hierarchical variables').)} @@ -77,8 +77,8 @@ attribuer la valeur de \code{rtauargus.totcode}.)} } \value{ Returns the names of the asc and rda files as a list (invisibly). -invisibly). Empty columns (filled with \code{NA} or empty strings) are not -strings) will not be exported to the asc file. A +Empty columns (filled with \code{NA} or empty strings) will not be +exported to the asc file. A warning message will list the affected columns. \cr (Renvoie les noms des fichiers asc et rda sous forme de liste (de manière invisible). Les colonnes vides (remplies de \code{NA} ou de chaînes @@ -94,7 +94,7 @@ or \code{tab_multi_manager()}, which offer a lot more features for your protection problems. See more details in \code{vignette("rtauargus")} or in -\verb{vignette("protect_multi_tables)}. +\code{vignette("protect_multi_tables")}. Creates a fixed length text file (asc) and a metadata file (rda) from microdata and additional information. \cr @@ -110,7 +110,7 @@ for each variable. The names of the elements of the vector give the variable concerned, the elements of the vector give the value of the parameter for Tau-Argus. An unnamed element -element will be the default value, which will be assigned to all +will be the default value, which will be assigned to all variables that can take this parameter. For example : @@ -149,7 +149,7 @@ to accept several ways of specifying the values associated with the hierarchical variables. To define a hierarchy based on the positions of characters -(\strong{hierierlevels}), pass a sequence of integers separated by +(\strong{hierlevels}), pass a sequence of integers separated by spaces. \emph{Example :} \code{c(CODECOM = "2 3 0 0 0")} @@ -158,7 +158,7 @@ If the hierarchy is defined in a separate hrc file (\strong{hiercodelist}), the function expects the location of this file (and a possible \code{hiercodelist} if it differs from the default option of the package). In this case, you can write explicitly the path to an existing file -file (\code{c(A38 = "a38.hrc")}), but also make a call to +(\code{c(A38 = "a38.hrc")}), but also make a call to \code{write_hrc()} which will generate an hrc file from microdata. \emph{Example :} \code{c(A38 = write_hrc(microdata, c("A38", "A21", "A10")))} @@ -216,7 +216,7 @@ soient nommés (avec le nom de la variable), même s'il n'y a qu'un seul \section{Number of decimals}{ -The parameter \code{decimals} indicates the minimum number of decimals to be +The parameter \code{decimals} indicates the minimum number of decimals to appear in the output file (whatever the number of decimals actually present in \code{microdata}). It applies to all real variables (double) but not to integer variables (integer). For diff --git a/man/micro_rtauargus.Rd b/man/micro_rtauargus.Rd index e9c0338..2309548 100644 --- a/man/micro_rtauargus.Rd +++ b/man/micro_rtauargus.Rd @@ -70,7 +70,7 @@ or \code{tab_multi_manager()}, which offer a lot more features for your protection problems. See more details in \code{vignette("rtauargus")} or in -\verb{vignette("protect_multi_tables)}. +\code{vignette("protect_multi_tables")}. Protects tables built from microdata and specifications of the crossings. The function allows to perform the complete process, namely the creation of @@ -93,7 +93,7 @@ The function executes sequentially the functions: \itemize{ Intermediate files without a name entered (\code{asc_filename}...) will be created in a temporary folder, with randomly generated names. This mechanism allows the user to abstract from the preparation of -preparation of the data and to maintain the entire chain of +the data and to maintain the entire chain of processing in R. \cr (La fonction exécute séquentiellement les fonctions : \itemize{ @@ -112,7 +112,7 @@ traitements dans R.) } \section{Microdata already as text files}{ -To use existing asc and rda files already existing, it is possible to +To use existing asc and rda files, it is possible to provide, instead of the data.frame, a character vector indicating the path of these files. The first element of this vector is the asc file, the second element the rda file. The rda file can be omitted if it has the diff --git a/man/rtauargus_options.Rd b/man/rtauargus_options.Rd index 0f46897..2cc18b0 100644 --- a/man/rtauargus_options.Rd +++ b/man/rtauargus_options.Rd @@ -36,7 +36,7 @@ name of the function prefixed by \code{rtauargus.} : user.} On loading the package, all the rtauargus options, that are not already -been set by the user, are set with their default values (see table below). +set by the user, are set with their default values (see table below). The already defined options keep the values set by the user. The options can be set during a session with the following instruction diff --git a/man/rtauargus_plus.Rd b/man/rtauargus_plus.Rd index 7c82291..88ba25d 100644 --- a/man/rtauargus_plus.Rd +++ b/man/rtauargus_plus.Rd @@ -75,7 +75,7 @@ croisements (ayant tous les mêmes paramètres).) \details{ In interactive mode, Tau-Argus can process up to 10 tabs simultaneously for the same microdata set. In batch mode, a larger number of -of crossings can be specified. However, doing so +crossings can be specified. However, doing so can be particularly time consuming, as Tau-Argus takes a lot of time to read large text files of microdata. @@ -83,7 +83,7 @@ to read large text files of microdata. splits the list of tabs into groups of size \code{grp_size} and makes a call to \code{micro_rtauargus()} for each group. It writes an asc file restricted to the only variables actually used within a -of a group. +group. The results are then aggregated into a single list, as if Tau-Argus had been called only once. @@ -91,7 +91,7 @@ had been called only once. Modifying \code{grp_size} will not change the result, only the time execution time. A value around 5 (default) seems to be a good compromise between reading too large asc files and calling Tau-Argus too often. -Tau-Argus too much. It can be adjusted according to the number of +It can be adjusted according to the number of common variables within each tab group. (En mode interactif, Tau-Argus peut traiter jusqu'à 10 tabulations simultanément pour un même jeu de microdonnées. En mode batch, un nombre plus @@ -119,7 +119,7 @@ variables communes à l'intérieur de chaque groupe de tabulations.) In return for the speed of execution, the crossings must have the same characteristics (same primary secret rules, same secondary secret method, -same secondary secret, same weighting variable, etc.). The parameters +same weighting variable, etc.). The parameters \code{safety_rules}, \code{supress}, ..., must therefore contain a unique value. diff --git a/man/run_arb.Rd b/man/run_arb.Rd index fe8e2fc..7f58f9f 100644 --- a/man/run_arb.Rd +++ b/man/run_arb.Rd @@ -76,14 +76,14 @@ This is the only function in the package that runs Tau-Argus. It therefore requires the software to be accessible from the workstation. The location of the TauArgus.exe program is defined globally when the -loading the package. In fact, the argument \code{tauargus_exe} will not +loading the package. In fact, the argument \code{tauargus_exe} will normally not have to be specified (except to override the global option the time of the execution of the function). Checks are made before the actual launching of Tau-Argus: existence of the software on the computer, of the asc and rda files, of the folders where write the results, the variables to be used (crossings, response variable) in the -response variable) in the metadata (rda file). \cr +metadata (rda file). \cr (Seul l’argument \code{arb_filename} est obligatoire, car toutes les informations nécessaires sont présentes dans ce fichier. diff --git a/man/tab_arb.Rd b/man/tab_arb.Rd index 64f14df..9dacb97 100644 --- a/man/tab_arb.Rd +++ b/man/tab_arb.Rd @@ -54,7 +54,7 @@ for example.\cr Chaîne de caractères en syntaxe batch Tau-Argus. Si le secret primaire a été traité dans un fichier d'apriori : utiliser "MAN(10)")} -\item{suppress}{Algortihm for secondary suppression (Tau-Argus batch syntax), and the +\item{suppress}{Algorithm for secondary suppression (Tau-Argus batch syntax), and the parameters for it.\cr ( Algorithme de gestion du secret secondaire (syntaxe batch de Tau-Argus), ainsi que les potentiels paramètres associés)} @@ -72,7 +72,7 @@ For SBS files use \code{"4"}\cr Valeur par défaut du package : \code{"2"} (csv for pivot-table). Pour le format SBS utiliser \code{"4"})} -\item{output_options}{Additionnal parameter for the output, +\item{output_options}{Additional parameter for the output, by default : \code{"AS+"} (print Status). To specify no options : \code{""}.\cr (Options supplémentaires des fichiers en sortie. Valeur par défaut du package : \code{"AS+"} (affichage du statut). Pour ne @@ -81,11 +81,11 @@ spécifier aucune option, \code{""}.)} \item{gointeractive}{Boolean, if TRUE will open a Tau-Argus window and launch the batch in it (\code{FALSE} by default). \cr (Possibilité de lancer le batch depuis le menu de Tau-Argus -(\code{FALSE} par défaut).)} +(\code{FALSE} par défaut).} } \value{ A list containing two elements : -the arb file name and the output name (usefull if the name is generated randomly) \cr +the arb file name and the output name (useful if the name is generated randomly) \cr (Une liste de deux éléments : le nom du fichier arb, le nom fichiers en sortie (utile pour récupérer les noms générés aléatoirement).) } @@ -98,7 +98,7 @@ si les fichiers asc et rda existent.) \section{Syntaxe}{ -For tabular data, this function secures only one table at a time#' +For tabular data, this function secures only one table at a time. Unless specific details, use syntax from Tau-Argus manual \cr Sauf mention contraire, utiliser la syntaxe mentionnée dans la documentation de Tau-Argus. diff --git a/man/tab_multi_manager.Rd b/man/tab_multi_manager.Rd index 9175a97..510482a 100644 --- a/man/tab_multi_manager.Rd +++ b/man/tab_multi_manager.Rd @@ -30,9 +30,9 @@ tab_multi_manager( \item{list_tables}{named list of \code{data.frame} or \code{data.table} representing the tables to protect} \item{list_explanatory_vars}{named list of character vectors of explanatory -variables of each table mentionned in list_tables. Names of the list are the same as of the list of tables.} +variables of each table mentioned in list_tables. Names of the list are the same as of the list of tables.} -\item{dir_name}{string indicated the path of the directory in which to save +\item{dir_name}{string indicating the path of the directory in which to save all the files (.rda, .hst, .txt, .arb, .csv) generated by the function.} \item{hrc}{Informations of hierarchical variables (see section @@ -61,7 +61,7 @@ attribuer la valeur de \code{rtauargus.totcode}.)} \item{freq}{Name of the column containing the cell frequency. \cr (Nom de la colonne contenant les effectifs pour une cellule)} -\item{secret_var}{Nae of the boolean variable which specifies the secret, primary or not : +\item{secret_var}{Name of the boolean variable which specifies the secret, primary or not : equal to "TRUE" if a cell is concerned by the secret,"FALSE" otherwise. will be exported in the apriori file. \cr (Variable indiquant le secret de type booléen: @@ -78,7 +78,7 @@ correspond à la valeur de la cellule. peut être spécifié pour chacune des c peut contenir des NA pour les coûts que l'on ne souhaite pas modifier.) (nombre minimal de décimales à afficher (voir section 'Number of decimals').)} -\item{suppress}{Algortihm for secondary suppression (Tau-Argus batch syntax), and the +\item{suppress}{Algorithm for secondary suppression (Tau-Argus batch syntax), and the parameters for it.\cr ( Algorithme de gestion du secret secondaire (syntaxe batch de Tau-Argus), ainsi que les potentiels paramètres associés)} diff --git a/man/tab_rda.Rd b/man/tab_rda.Rd index 8b38807..b986df2 100644 --- a/man/tab_rda.Rd +++ b/man/tab_rda.Rd @@ -50,7 +50,7 @@ Example : \code{c("A21", "TREFF", "REG")} for a table crossing prend la valeur "TRUE" quand les cellules du tableau doivent être masquées par le secret primaire, "FALSE" sinon. Permet de créer un fichier d'apriori)} -\item{secret_var}{Nae of the boolean variable which specifies the secret, primary or not : +\item{secret_var}{Name of the boolean variable which specifies the secret, primary or not : equal to "TRUE" if a cell is concerned by the secret,"FALSE" otherwise. will be exported in the apriori file. \cr (Variable indiquant le secret de type booléen: @@ -194,7 +194,7 @@ toutes les variables catégorielles} \verb{ "global"} pour toutes les variables catégorielles sauf \code{size} and \code{income}} qui se verront affecter le total : \verb{ "total"} -Par defaut : \verb{ "Total"} +Par défaut : \verb{ "Total"} } } @@ -226,7 +226,7 @@ Le chemin vers le fichier existant est explicitement donné. Les éléments du vecteur en paramètre doivent nommés (avec le nom de la variable), même s'il n'y a qu'un seul élément. -\emph{Exemple :}\code{c(category="category.hrc")}) +\emph{Exemple :} \code{c(category="category.hrc")} } \section{Number of decimals}{ diff --git a/man/tab_rtauargus.Rd b/man/tab_rtauargus.Rd index 01a2c99..28936c1 100644 --- a/man/tab_rtauargus.Rd +++ b/man/tab_rtauargus.Rd @@ -47,7 +47,7 @@ par le secret primaire, "FALSE" sinon. Permet de créer un fichier d'apriori)} \item{files_name}{string used to name all the files needed to process. All files will have the same name, only their extension will be different.} -\item{dir_name}{string indicated the path of the directory in which to save +\item{dir_name}{string indicating the path of the directory in which to save all the files (.rda, .hst, .txt, .arb, .csv) generated by the function.} \item{totcode}{Code(s) which represent the total of a categorical variable @@ -66,7 +66,7 @@ attribuer la valeur de \code{rtauargus.totcode}.)} (Caractère qui, répété n fois, indique que la valeur est à n niveaux de profondeur dans la hiérarchie.)} -\item{secret_var}{Nae of the boolean variable which specifies the secret, primary or not : +\item{secret_var}{Name of the boolean variable which specifies the secret, primary or not : equal to "TRUE" if a cell is concerned by the secret,"FALSE" otherwise. will be exported in the apriori file. \cr (Variable indiquant le secret de type booléen: @@ -102,7 +102,7 @@ contributor of a cell. \cr (Nom de la colonne contenant la valeur du plus gros contributeur d'une cellule)} -\item{suppress}{Algortihm for secondary suppression (Tau-Argus batch syntax), and the +\item{suppress}{Algorithm for secondary suppression (Tau-Argus batch syntax), and the parameters for it.\cr ( Algorithme de gestion du secret secondaire (syntaxe batch de Tau-Argus), ainsi que les potentiels paramètres associés)} @@ -128,7 +128,7 @@ For SBS files use \code{"4"}\cr Valeur par défaut du package : \code{"2"} (csv for pivot-table). Pour le format SBS utiliser \code{"4"})} -\item{output_options}{Additionnal parameter for the output, +\item{output_options}{Additional parameter for the output, by default : \code{"AS+"} (print Status). To specify no options : \code{""}.\cr (Options supplémentaires des fichiers en sortie. Valeur par défaut du package : \code{"AS+"} (affichage du statut). Pour ne diff --git a/man/tab_rtauargus2.Rd b/man/tab_rtauargus2.Rd index d4af95e..46aac38 100644 --- a/man/tab_rtauargus2.Rd +++ b/man/tab_rtauargus2.Rd @@ -32,7 +32,7 @@ une variable supplémentaire indiquant le secret primaire de type booléen.)} \item{files_name}{string used to name all the files needed to process. All files will have the same name, only their extension will be different.} -\item{dir_name}{string indicated the path of the directory in which to save +\item{dir_name}{string indicating the path of the directory in which to save all the files (.rda, .hst, .txt, .arb, .csv) generated by the function.} \item{explanatory_vars}{Vector of explanatory variables \cr @@ -59,7 +59,7 @@ attribuer la valeur de \code{rtauargus.totcode}.)} (Caractère qui, répété n fois, indique que la valeur est à n niveaux de profondeur dans la hiérarchie.)} -\item{secret_var}{Nae of the boolean variable which specifies the secret, primary or not : +\item{secret_var}{Name of the boolean variable which specifies the secret, primary or not : equal to "TRUE" if a cell is concerned by the secret,"FALSE" otherwise. will be exported in the apriori file. \cr (Variable indiquant le secret de type booléen: @@ -89,7 +89,7 @@ peut contenir des NA pour les coûts que l'on ne souhaite pas modifier.) \item{ip}{Interval Protection Level (10 by default)} -\item{suppress}{Algortihm for secondary suppression (Tau-Argus batch syntax), and the +\item{suppress}{Algorithm for secondary suppression (Tau-Argus batch syntax), and the parameters for it.\cr ( Algorithme de gestion du secret secondaire (syntaxe batch de Tau-Argus), ainsi que les potentiels paramètres associés)} diff --git a/man/tab_rtauargus4.Rd b/man/tab_rtauargus4.Rd index 3bbdb60..e08dc26 100644 --- a/man/tab_rtauargus4.Rd +++ b/man/tab_rtauargus4.Rd @@ -42,10 +42,10 @@ Example : \code{c("A21", "TREFF", "REG")} for a table crossing prend la valeur "TRUE" quand les cellules du tableau doivent être masquées par le secret primaire, "FALSE" sinon. Permet de créer un fichier d'apriori)} -\item{dir_name}{string indicated the path of the directory in which to save +\item{dir_name}{string indicating the path of the directory in which to save all the files (.rda, .hst, .txt, .arb, .csv) generated by the function.} -\item{secret_var}{Nae of the boolean variable which specifies the secret, primary or not : +\item{secret_var}{Name of the boolean variable which specifies the secret, primary or not : equal to "TRUE" if a cell is concerned by the secret,"FALSE" otherwise. will be exported in the apriori file. \cr (Variable indiquant le secret de type booléen: @@ -95,7 +95,7 @@ peut contenir des NA pour les coûts que l'on ne souhaite pas modifier.) \item{ip}{Value of the safety margin in \% (must be an integer). (Valeur pour les intervalles de protection en \%, doit être entier )} -\item{suppress}{Algortihm for secondary suppression (Tau-Argus batch syntax), and the +\item{suppress}{Algorithm for secondary suppression (Tau-Argus batch syntax), and the parameters for it.\cr ( Algorithme de gestion du secret secondaire (syntaxe batch de Tau-Argus), ainsi que les potentiels paramètres associés)} diff --git a/man/write_hrc.Rd b/man/write_hrc.Rd index dec1ea8..199efc2 100644 --- a/man/write_hrc.Rd +++ b/man/write_hrc.Rd @@ -34,7 +34,7 @@ filled, a temporary file.\cr \item{fill_na}{fill in any missing values, using an other variable : \itemize{ -\item{\code{"up"} (default) : hierarchical variable of the level level +\item{\code{"up"} (default) : hierarchical variable of the level immediately above} \item{\code{"down"} : hierarchical variable of the level immediately lower} diff --git a/man/write_hrc2.Rd b/man/write_hrc2.Rd index 644ebeb..af17011 100644 --- a/man/write_hrc2.Rd +++ b/man/write_hrc2.Rd @@ -34,7 +34,7 @@ Si TRUE, inverse l'ordre des colonnes.} \item{hier_lead_string}{character. (Single) character indicating the hierarchy depth in the .hrc file. By default, the value is set to the current -value mentionned in the package options (i.e. "@" at the package startup). +value mentioned in the package options (i.e. "@" at the package startup). \cr Caractère unique repérant le niveau de profondeur dans le .hrc} @@ -52,7 +52,7 @@ default = "ZZZ" \cr character Si adjust_unique_roots est TRUE add_char est l'élément qui sera utilisé afin de créer des feuilles fictives, il faut être sur que cela ne crée pas de doublons dans la hiérarchie.La chaine de caractère sera -ajouté au début d'une feuille unique. Par defaut :"ZZZ"} +ajouté au début d'une feuille unique. Par défaut : "ZZZ"} } \value{ Invisible. Path to the written .hrc file. @@ -69,7 +69,7 @@ correspondence table fully describing it. By default, lines are sorted alphabetically so as to regroup identical levels. Ecrit un fichier de hiérarchie .hrc lisible par tau-Argus à -partir d'une table de corrrespondance la décrivant complètement. Par défaut, +partir d'une table de correspondance la décrivant complètement. Par défaut, les lignes du tableau seront triées afin de regrouper les niveaux de hiérarchie identiques. } diff --git a/vignettes/auto_metadata.Rmd b/vignettes/auto_metadata.Rmd index 229215e..91a310d 100644 --- a/vignettes/auto_metadata.Rmd +++ b/vignettes/auto_metadata.Rmd @@ -60,7 +60,7 @@ The function arguments are as follows: - `df_metadata`: a dataframe structured as specified in section \ref{sec:crea_meta}. - `df_eq_indicator` : a dataframe of equations on indicators. -- `verbose`: a variable of type `logical`. If `TRUE` he function returns a list with the different steps of the analysis; if `FALSE`, it returns only the final dataframe with the cluster indicator. +- `verbose`: a variable of type `logical`. If `TRUE` the function returns a list with the different steps of the analysis; if `FALSE`, it returns only the final dataframe with the cluster indicator. The `df_eq_indicator` data frame consists of three columns that must follow the format below: @@ -141,16 +141,16 @@ cluster_id_dataframe ``` ``` -## cluster table_name field indicator spanning_1 spanning_2 spanning_3 hrc_spanning_1 hrc_spanning_2 -## 1 france_entreprises_2023.hrc_lettuce T10.T12.T8 france_entreprises_2023 LETTUCE HRC_NAF cj HRC_LETTUCE^h hrc_naf -## 2 france_entreprises_2023.hrc_lettuce T11.T7.T9 france_entreprises_2023 LETTUCE HRC_NAF size HRC_LETTUCE^h hrc_naf -## 3 france_entreprises_2023.to_pizza T1.T2 france_entreprises_2023 to_pizza HRC_NUTS size hrc_nuts -## 4 france_entreprises_2023.to_pizza T3.T4.T5.T6 france_entreprises_2023 to_pizza HRC_NAF HRC_NUTS hrc_naf hrc_nuts -## hrc_spanning_3 -## 1 hrc_lettuce -## 2 hrc_lettuce -## 3 -## 4 +## cluster table_name field indicator spanning_1 spanning_2 spanning_3 +## 1 france_entreprises_2023.hrc_lettuce T10.T12.T8 france_entreprises_2023 LETTUCE HRC_NAF cj HRC_LETTUCE^h +## 2 france_entreprises_2023.hrc_lettuce T11.T7.T9 france_entreprises_2023 LETTUCE HRC_NAF size HRC_LETTUCE^h +## 3 france_entreprises_2023.to_pizza T1.T2 france_entreprises_2023 to_pizza HRC_NUTS size +## 4 france_entreprises_2023.to_pizza T3.T4.T5.T6 france_entreprises_2023 to_pizza HRC_NAF HRC_NUTS +## hrc_spanning_1 hrc_spanning_2 hrc_spanning_3 +## 1 hrc_naf hrc_lettuce +## 2 hrc_naf hrc_lettuce +## 3 hrc_nuts +## 4 hrc_naf hrc_nuts ``` For the 12 tables to be published, it is sufficient to protect 4 tables. These tables are distributed across two different clusters. Therefore, `tab_multi_manager()` needs to be called twice. @@ -164,8 +164,8 @@ names(detailed_analysis) ``` ``` -## [1] "identify_hrc" "info_var" "split_in_clusters" "create_edges" "grp_tab_names" "grp_tab_in_clusters" -## [7] "tab_to_treat" "df_tab_to_treat" +## [1] "identify_hrc" "info_var" "split_in_clusters" "create_edges" "grp_tab_names" +## [6] "grp_tab_in_clusters" "tab_to_treat" "df_tab_to_treat" ``` One finds the dataframe with the cluster indicator `df_tab_to_treat`. The result is the same but in list format: each element of the list is an independent cluster `tab_to_treat`. Additionally, the 6 steps of the analysis are included. @@ -213,13 +213,13 @@ template_formatted$metadata ``` ``` -## table_name field indicator spanning_1 spanning_2 hrc_spanning_1 hrc_spanning_2 -## 1 table_2021_SAL_DTH_1 2021 SAL_DTH ACTIVITY LEGAL_FORM hrc_activity_131 hrc_legal_form_3 -## 2 table_2021_SAL_DTH_2 2021 SAL_DTH ACTIVITY NUMBER_EMPL hrc_activity_131 hrc_number_empl_4 -## 3 table_2022_SAL_1 2022 SAL ACTIVITY LEGAL_FORM hrc_activity_131 hrc_legal_form_3 -## 4 table_2022_SAL_2 2022 SAL ACTIVITY NUMBER_EMPL hrc_activity_131 hrc_number_empl_4 -## 5 table_2022_SAL_DTH_1 2022 SAL_DTH ACTIVITY LEGAL_FORM hrc_activity_131 hrc_legal_form_3 -## 6 table_2022_SAL_DTH_2 2022 SAL_DTH ACTIVITY NUMBER_EMPL hrc_activity_131 hrc_number_empl_4 +## table_name field indicator spanning_1 spanning_2 hrc_spanning_1 hrc_spanning_2 +## 1 table_2021_SAL_DTH_1 2021 SAL_DTH ACTIVITY_131 LEGAL_FORM_3 hrc_activity hrc_legal_form +## 2 table_2021_SAL_DTH_2 2021 SAL_DTH ACTIVITY_131 NUMBER_EMPL_4 hrc_activity hrc_number_empl +## 3 table_2022_SAL_1 2022 SAL ACTIVITY_131 LEGAL_FORM_3 hrc_activity hrc_legal_form +## 4 table_2022_SAL_2 2022 SAL ACTIVITY_131 NUMBER_EMPL_4 hrc_activity hrc_number_empl +## 5 table_2022_SAL_DTH_1 2022 SAL_DTH ACTIVITY_131 LEGAL_FORM_3 hrc_activity hrc_legal_form +## 6 table_2022_SAL_DTH_2 2022 SAL_DTH ACTIVITY_131 NUMBER_EMPL_4 hrc_activity hrc_number_empl ``` There are 6 tables to be published. @@ -240,13 +240,13 @@ metadata_template ``` ``` -## table_name field indicator hrc_indicator spanning_1 spanning_2 hrc_spanning_1 hrc_spanning_2 hrc_field -## 1 table_2021_SAL_DTH_1 2021 SAL_DTH NA ACTIVITY LEGAL_FORM hrc_activity_131 hrc_legal_form_3 NA -## 2 table_2021_SAL_DTH_2 2021 SAL_DTH NA ACTIVITY NUMBER_EMPL hrc_activity_131 hrc_number_empl_4 NA -## 3 table_2022_SAL_1 2022 SAL NA ACTIVITY LEGAL_FORM hrc_activity_131 hrc_legal_form_3 NA -## 4 table_2022_SAL_2 2022 SAL NA ACTIVITY NUMBER_EMPL hrc_activity_131 hrc_number_empl_4 NA -## 5 table_2022_SAL_DTH_1 2022 SAL_DTH NA ACTIVITY LEGAL_FORM hrc_activity_131 hrc_legal_form_3 NA -## 6 table_2022_SAL_DTH_2 2022 SAL_DTH NA ACTIVITY NUMBER_EMPL hrc_activity_131 hrc_number_empl_4 NA +## table_name field indicator hrc_indicator spanning_1 spanning_2 hrc_spanning_1 hrc_spanning_2 hrc_field +## 1 table_2021_SAL_DTH_1 2021 SAL_DTH NA ACTIVITY_131 LEGAL_FORM_3 hrc_activity hrc_legal_form NA +## 2 table_2021_SAL_DTH_2 2021 SAL_DTH NA ACTIVITY_131 NUMBER_EMPL_4 hrc_activity hrc_number_empl NA +## 3 table_2022_SAL_1 2022 SAL NA ACTIVITY_131 LEGAL_FORM_3 hrc_activity hrc_legal_form NA +## 4 table_2022_SAL_2 2022 SAL NA ACTIVITY_131 NUMBER_EMPL_4 hrc_activity hrc_number_empl NA +## 5 table_2022_SAL_DTH_1 2022 SAL_DTH NA ACTIVITY_131 LEGAL_FORM_3 hrc_activity hrc_legal_form NA +## 6 table_2022_SAL_DTH_2 2022 SAL_DTH NA ACTIVITY_131 NUMBER_EMPL_4 hrc_activity hrc_number_empl NA ``` Next, this dataframe is used as input for the analysis function. @@ -264,13 +264,13 @@ cluster_id_dataframe ``` ``` -## cluster table_name field indicator spanning_1 spanning_2 hrc_spanning_1 hrc_spanning_2 -## 1 2021.SAL_DTH table_2021_SAL_DTH_1 2021 SAL_DTH HRC_ACTIVITY_131 HRC_LEGAL_FORM_3 hrc_activity_131 hrc_legal_form_3 -## 2 2021.SAL_DTH table_2021_SAL_DTH_2 2021 SAL_DTH HRC_ACTIVITY_131 HRC_NUMBER_EMPL_4 hrc_activity_131 hrc_number_empl_4 -## 3 2022.SAL table_2022_SAL_1 2022 SAL HRC_ACTIVITY_131 HRC_LEGAL_FORM_3 hrc_activity_131 hrc_legal_form_3 -## 4 2022.SAL table_2022_SAL_2 2022 SAL HRC_ACTIVITY_131 HRC_NUMBER_EMPL_4 hrc_activity_131 hrc_number_empl_4 -## 5 2022.SAL_DTH table_2022_SAL_DTH_1 2022 SAL_DTH HRC_ACTIVITY_131 HRC_LEGAL_FORM_3 hrc_activity_131 hrc_legal_form_3 -## 6 2022.SAL_DTH table_2022_SAL_DTH_2 2022 SAL_DTH HRC_ACTIVITY_131 HRC_NUMBER_EMPL_4 hrc_activity_131 hrc_number_empl_4 +## cluster table_name field indicator spanning_1 spanning_2 hrc_spanning_1 hrc_spanning_2 +## 1 2021.SAL_DTH table_2021_SAL_DTH_1 2021 SAL_DTH HRC_ACTIVITY HRC_LEGAL_FORM hrc_activity hrc_legal_form +## 2 2021.SAL_DTH table_2021_SAL_DTH_2 2021 SAL_DTH HRC_ACTIVITY HRC_NUMBER_EMPL hrc_activity hrc_number_empl +## 3 2022.SAL table_2022_SAL_1 2022 SAL HRC_ACTIVITY HRC_LEGAL_FORM hrc_activity hrc_legal_form +## 4 2022.SAL table_2022_SAL_2 2022 SAL HRC_ACTIVITY HRC_NUMBER_EMPL hrc_activity hrc_number_empl +## 5 2022.SAL_DTH table_2022_SAL_DTH_1 2022 SAL_DTH HRC_ACTIVITY HRC_LEGAL_FORM hrc_activity hrc_legal_form +## 6 2022.SAL_DTH table_2022_SAL_DTH_2 2022 SAL_DTH HRC_ACTIVITY HRC_NUMBER_EMPL hrc_activity hrc_number_empl ``` Ultimately, there are 6 tables to process in 3 different clusters. In other words, `tab_multi_manager()` will need to be called three times. @@ -324,6 +324,12 @@ detailed_analysis <- analyse_metadata(metadata_pizza_lettuce, ## the hrc_indicator column will be ignored. ``` +``` +## Warning in identify_hrc_with_eq(df_metadata_long, df_eq_indicator): Check the coherence of `df_eq_indicator` and `df_metadata`. +## There is no table description in `df_metadata` with an indicator that is part of one of the equations provided in `df_eq_indicator`. +## `df_eq_indicator` is useless here and will be ignored. +``` + ``` r # Simplified output, only the data frame with the cluster indicator cluster_id_dataframe <- analyse_metadata(metadata_pizza_lettuce, verbose = FALSE) @@ -341,16 +347,16 @@ cluster_id_dataframe ``` ``` -## cluster table_name field indicator spanning_1 spanning_2 spanning_3 hrc_spanning_1 hrc_spanning_2 -## 1 france_entreprises_2023.hrc_lettuce T10.T12.T8 france_entreprises_2023 LETTUCE HRC_NAF cj HRC_LETTUCE^h hrc_naf -## 2 france_entreprises_2023.hrc_lettuce T11.T7.T9 france_entreprises_2023 LETTUCE HRC_NAF size HRC_LETTUCE^h hrc_naf -## 3 france_entreprises_2023.to_pizza T1.T2 france_entreprises_2023 to_pizza HRC_NUTS size hrc_nuts -## 4 france_entreprises_2023.to_pizza T3.T4.T5.T6 france_entreprises_2023 to_pizza HRC_NAF HRC_NUTS hrc_naf hrc_nuts -## hrc_spanning_3 -## 1 hrc_lettuce -## 2 hrc_lettuce -## 3 -## 4 +## cluster table_name field indicator spanning_1 spanning_2 spanning_3 +## 1 france_entreprises_2023.hrc_lettuce T10.T12.T8 france_entreprises_2023 LETTUCE HRC_NAF cj HRC_LETTUCE^h +## 2 france_entreprises_2023.hrc_lettuce T11.T7.T9 france_entreprises_2023 LETTUCE HRC_NAF size HRC_LETTUCE^h +## 3 france_entreprises_2023.to_pizza T1.T2 france_entreprises_2023 to_pizza HRC_NUTS size +## 4 france_entreprises_2023.to_pizza T3.T4.T5.T6 france_entreprises_2023 to_pizza HRC_NAF HRC_NUTS +## hrc_spanning_1 hrc_spanning_2 hrc_spanning_3 +## 1 hrc_naf hrc_lettuce +## 2 hrc_naf hrc_lettuce +## 3 hrc_nuts +## 4 hrc_naf hrc_nuts ``` diff --git a/vignettes/auto_metadata.Rmd.orig b/vignettes/auto_metadata.Rmd.orig index afba68a..01ed5ec 100644 --- a/vignettes/auto_metadata.Rmd.orig +++ b/vignettes/auto_metadata.Rmd.orig @@ -55,7 +55,7 @@ The function arguments are as follows: - `df_metadata`: a dataframe structured as specified in section \ref{sec:crea_meta}. - `df_eq_indicator` : a dataframe of equations on indicators. -- `verbose`: a variable of type `logical`. If `TRUE` he function returns a list with the different steps of the analysis; if `FALSE`, it returns only the final dataframe with the cluster indicator. +- `verbose`: a variable of type `logical`. If `TRUE` the function returns a list with the different steps of the analysis; if `FALSE`, it returns only the final dataframe with the cluster indicator. The `df_eq_indicator` data frame consists of three columns that must follow the format below: ```{r} diff --git a/vignettes/auto_metadata_fr.Rmd b/vignettes/auto_metadata_fr.Rmd index 44ae776..8f58340 100644 --- a/vignettes/auto_metadata_fr.Rmd +++ b/vignettes/auto_metadata_fr.Rmd @@ -23,9 +23,9 @@ library(dplyr) # Introduction -Avant de faire appel aux fonctions permettant la pose du secret il est nécessaire d'analyser les tableaux que l'on souhaite protéger. En effet,les tableaux diffusés sont différents des tableaux à protéger. Cela est expliqué en détail au chapitre 3 du [Manuel de protection des tableaux](https://inseefrlab.github.io/manuel-protection-tableaux/03_analyser_une_demande.html). Cette phase d'analyse des marges communes entre les différents tableaux peut s'avérer complexe. Ainsi, des fonctions ont été développées dans `rtauargus` pour faciliter ce travail. +Avant de faire appel aux fonctions permettant la pose du secret il est nécessaire d'analyser les tableaux que l'on souhaite protéger. En effet, les tableaux diffusés sont différents des tableaux à protéger. Cela est expliqué en détail au chapitre 3 du [Manuel de protection des tableaux](https://inseefrlab.github.io/manuel-protection-tableaux/03_analyser_une_demande.html). Cette phase d'analyse des marges communes entre les différents tableaux peut s'avérer complexe. Ainsi, des fonctions ont été développées dans `rtauargus` pour faciliter ce travail. -# Comment fonctionne l'analyse automatique automatique des métadonnées ? +# Comment fonctionne l'analyse automatique des métadonnées ? ## Création des métadonnées \label{sec:crea_meta} Les métadonnées doivent respecter un format spécifique. Une ligne représente un tableau et pour chaque tableau il faut préciser : @@ -124,7 +124,14 @@ Exemple de code : library(rtauargus) data(metadata_pizza_lettuce) +``` + +``` +## Error in `load()`: +## ! fichier d'entrée vide (0 octets) +``` +``` r # Analyse complète, avec les étapes detailed_analysis <- analyse_metadata(metadata_pizza_lettuce, verbose = TRUE) @@ -140,19 +147,19 @@ cluster_id_dataframe ``` ``` -## cluster table_name field indicator spanning_1 spanning_2 spanning_3 hrc_spanning_1 hrc_spanning_2 -## 1 france_entreprises_2023.hrc_lettuce T10.T12.T8 france_entreprises_2023 LETTUCE HRC_NAF cj HRC_LETTUCE^h hrc_naf -## 2 france_entreprises_2023.hrc_lettuce T11.T7.T9 france_entreprises_2023 LETTUCE HRC_NAF size HRC_LETTUCE^h hrc_naf -## 3 france_entreprises_2023.to_pizza T1.T2 france_entreprises_2023 to_pizza HRC_NUTS size hrc_nuts -## 4 france_entreprises_2023.to_pizza T3.T4.T5.T6 france_entreprises_2023 to_pizza HRC_NAF HRC_NUTS hrc_naf hrc_nuts -## hrc_spanning_3 -## 1 hrc_lettuce -## 2 hrc_lettuce -## 3 -## 4 +## cluster table_name field indicator spanning_1 spanning_2 spanning_3 +## 1 france_entreprises_2023.hrc_lettuce T10.T12.T8 france_entreprises_2023 LETTUCE HRC_NAF cj HRC_LETTUCE^h +## 2 france_entreprises_2023.hrc_lettuce T11.T7.T9 france_entreprises_2023 LETTUCE HRC_NAF size HRC_LETTUCE^h +## 3 france_entreprises_2023.to_pizza T1.T2 france_entreprises_2023 to_pizza HRC_NUTS size +## 4 france_entreprises_2023.to_pizza T3.T4.T5.T6 france_entreprises_2023 to_pizza HRC_NAF HRC_NUTS +## hrc_spanning_1 hrc_spanning_2 hrc_spanning_3 +## 1 hrc_naf hrc_lettuce +## 2 hrc_naf hrc_lettuce +## 3 hrc_nuts +## 4 hrc_naf hrc_nuts ``` -Pour les 12 tableaux à publier il suffit de protéger 4 tableaux. Ces tableaux sont repartis dans deux clusters différents. Il faudra donc faire appel deux fois à `tab_multi_manager()`. +Pour les 12 tableaux à publier il suffit de protéger 4 tableaux. Ces tableaux sont répartis dans deux clusters différents. Il faudra donc faire appel deux fois à `tab_multi_manager()`. On remarque une nouvelle variable de croisement `HRC_LETTUCE^h`. Il s'agit d'une variable qui prend pour modalités `batavia` et `arugula` et a pour total `lettuce`. L'indicateur `LETTUCE` renvoie ici au "turnover" (to) ou "chiffre d'affaires" de la vente de salades. Par exemple, le tableau `T10.T12.T8` présente le chiffre d'affaires de la vente de salades en fonction de l'activité et de la catégorie de l'entreprise ainsi que du type de salade. Si l'on souhaite avoir plus d'informations sur l'analyse de la demande, on peut spécifier l'argument `verbose = TRUE`. Ainsi, l'objet renvoyé par la fonction est une liste des différentes étapes de l'analyse. @@ -163,8 +170,8 @@ names(detailed_analysis) ``` ``` -## [1] "identify_hrc" "info_var" "split_in_clusters" "create_edges" "grp_tab_names" "grp_tab_in_clusters" -## [7] "tab_to_treat" "df_tab_to_treat" +## [1] "identify_hrc" "info_var" "split_in_clusters" "create_edges" "grp_tab_names" +## [6] "grp_tab_in_clusters" "tab_to_treat" "df_tab_to_treat" ``` On retrouve le dataframe avec l'indicatrice du cluster `df_tab_to_treat`. On a le même résultat mais en format liste : chaque élément de la sous-liste `tab_to_treat` est un cluster indépendant. Les autres éléments de la liste sont les étapes de l'analyse. @@ -212,13 +219,13 @@ template_formatted$metadata ``` ``` -## table_name field indicator spanning_1 spanning_2 hrc_spanning_1 hrc_spanning_2 -## 1 table_2021_SAL_DTH_1 2021 SAL_DTH ACTIVITY LEGAL_FORM hrc_activity_131 hrc_legal_form_3 -## 2 table_2021_SAL_DTH_2 2021 SAL_DTH ACTIVITY NUMBER_EMPL hrc_activity_131 hrc_number_empl_4 -## 3 table_2022_SAL_1 2022 SAL ACTIVITY LEGAL_FORM hrc_activity_131 hrc_legal_form_3 -## 4 table_2022_SAL_2 2022 SAL ACTIVITY NUMBER_EMPL hrc_activity_131 hrc_number_empl_4 -## 5 table_2022_SAL_DTH_1 2022 SAL_DTH ACTIVITY LEGAL_FORM hrc_activity_131 hrc_legal_form_3 -## 6 table_2022_SAL_DTH_2 2022 SAL_DTH ACTIVITY NUMBER_EMPL hrc_activity_131 hrc_number_empl_4 +## table_name field indicator spanning_1 spanning_2 hrc_spanning_1 hrc_spanning_2 +## 1 table_2021_SAL_DTH_1 2021 SAL_DTH ACTIVITY_131 LEGAL_FORM_3 hrc_activity hrc_legal_form +## 2 table_2021_SAL_DTH_2 2021 SAL_DTH ACTIVITY_131 NUMBER_EMPL_4 hrc_activity hrc_number_empl +## 3 table_2022_SAL_1 2022 SAL ACTIVITY_131 LEGAL_FORM_3 hrc_activity hrc_legal_form +## 4 table_2022_SAL_2 2022 SAL ACTIVITY_131 NUMBER_EMPL_4 hrc_activity hrc_number_empl +## 5 table_2022_SAL_DTH_1 2022 SAL_DTH ACTIVITY_131 LEGAL_FORM_3 hrc_activity hrc_legal_form +## 6 table_2022_SAL_DTH_2 2022 SAL_DTH ACTIVITY_131 NUMBER_EMPL_4 hrc_activity hrc_number_empl ``` On voit qu'il y a 6 tableaux à publier. @@ -239,13 +246,13 @@ metadata_template ``` ``` -## table_name field indicator hrc_indicator spanning_1 spanning_2 hrc_spanning_1 hrc_spanning_2 hrc_field -## 1 table_2021_SAL_DTH_1 2021 SAL_DTH NA ACTIVITY LEGAL_FORM hrc_activity_131 hrc_legal_form_3 NA -## 2 table_2021_SAL_DTH_2 2021 SAL_DTH NA ACTIVITY NUMBER_EMPL hrc_activity_131 hrc_number_empl_4 NA -## 3 table_2022_SAL_1 2022 SAL NA ACTIVITY LEGAL_FORM hrc_activity_131 hrc_legal_form_3 NA -## 4 table_2022_SAL_2 2022 SAL NA ACTIVITY NUMBER_EMPL hrc_activity_131 hrc_number_empl_4 NA -## 5 table_2022_SAL_DTH_1 2022 SAL_DTH NA ACTIVITY LEGAL_FORM hrc_activity_131 hrc_legal_form_3 NA -## 6 table_2022_SAL_DTH_2 2022 SAL_DTH NA ACTIVITY NUMBER_EMPL hrc_activity_131 hrc_number_empl_4 NA +## table_name field indicator hrc_indicator spanning_1 spanning_2 hrc_spanning_1 hrc_spanning_2 hrc_field +## 1 table_2021_SAL_DTH_1 2021 SAL_DTH NA ACTIVITY_131 LEGAL_FORM_3 hrc_activity hrc_legal_form NA +## 2 table_2021_SAL_DTH_2 2021 SAL_DTH NA ACTIVITY_131 NUMBER_EMPL_4 hrc_activity hrc_number_empl NA +## 3 table_2022_SAL_1 2022 SAL NA ACTIVITY_131 LEGAL_FORM_3 hrc_activity hrc_legal_form NA +## 4 table_2022_SAL_2 2022 SAL NA ACTIVITY_131 NUMBER_EMPL_4 hrc_activity hrc_number_empl NA +## 5 table_2022_SAL_DTH_1 2022 SAL_DTH NA ACTIVITY_131 LEGAL_FORM_3 hrc_activity hrc_legal_form NA +## 6 table_2022_SAL_DTH_2 2022 SAL_DTH NA ACTIVITY_131 NUMBER_EMPL_4 hrc_activity hrc_number_empl NA ``` Ensuite, on utilise ce dataframe en input de la fonction d'analyse. @@ -263,13 +270,13 @@ cluster_id_dataframe ``` ``` -## cluster table_name field indicator spanning_1 spanning_2 hrc_spanning_1 hrc_spanning_2 -## 1 2021.SAL_DTH table_2021_SAL_DTH_1 2021 SAL_DTH HRC_ACTIVITY_131 HRC_LEGAL_FORM_3 hrc_activity_131 hrc_legal_form_3 -## 2 2021.SAL_DTH table_2021_SAL_DTH_2 2021 SAL_DTH HRC_ACTIVITY_131 HRC_NUMBER_EMPL_4 hrc_activity_131 hrc_number_empl_4 -## 3 2022.SAL table_2022_SAL_1 2022 SAL HRC_ACTIVITY_131 HRC_LEGAL_FORM_3 hrc_activity_131 hrc_legal_form_3 -## 4 2022.SAL table_2022_SAL_2 2022 SAL HRC_ACTIVITY_131 HRC_NUMBER_EMPL_4 hrc_activity_131 hrc_number_empl_4 -## 5 2022.SAL_DTH table_2022_SAL_DTH_1 2022 SAL_DTH HRC_ACTIVITY_131 HRC_LEGAL_FORM_3 hrc_activity_131 hrc_legal_form_3 -## 6 2022.SAL_DTH table_2022_SAL_DTH_2 2022 SAL_DTH HRC_ACTIVITY_131 HRC_NUMBER_EMPL_4 hrc_activity_131 hrc_number_empl_4 +## cluster table_name field indicator spanning_1 spanning_2 hrc_spanning_1 hrc_spanning_2 +## 1 2021.SAL_DTH table_2021_SAL_DTH_1 2021 SAL_DTH HRC_ACTIVITY HRC_LEGAL_FORM hrc_activity hrc_legal_form +## 2 2021.SAL_DTH table_2021_SAL_DTH_2 2021 SAL_DTH HRC_ACTIVITY HRC_NUMBER_EMPL hrc_activity hrc_number_empl +## 3 2022.SAL table_2022_SAL_1 2022 SAL HRC_ACTIVITY HRC_LEGAL_FORM hrc_activity hrc_legal_form +## 4 2022.SAL table_2022_SAL_2 2022 SAL HRC_ACTIVITY HRC_NUMBER_EMPL hrc_activity hrc_number_empl +## 5 2022.SAL_DTH table_2022_SAL_DTH_1 2022 SAL_DTH HRC_ACTIVITY HRC_LEGAL_FORM hrc_activity hrc_legal_form +## 6 2022.SAL_DTH table_2022_SAL_DTH_2 2022 SAL_DTH HRC_ACTIVITY HRC_NUMBER_EMPL hrc_activity hrc_number_empl ``` Finalement, il y a 6 tableaux à traiter dans 3 clusters différents. Autrement dit, il faudra faire trois fois appel à `tab_multi_manager()`. @@ -322,6 +329,12 @@ detailed_analysis <- analyse_metadata(metadata_pizza_lettuce, ## the hrc_indicator column will be ignored. ``` +``` +## Warning in identify_hrc_with_eq(df_metadata_long, df_eq_indicator): Check the coherence of `df_eq_indicator` and `df_metadata`. +## There is no table description in `df_metadata` with an indicator that is part of one of the equations provided in `df_eq_indicator`. +## `df_eq_indicator` is useless here and will be ignored. +``` + ``` r # Output simplifié, uniquement le dataframe avec l'indicatrice de cluster cluster_id_dataframe <- analyse_metadata(metadata_pizza_lettuce, verbose = FALSE) @@ -340,16 +353,16 @@ cluster_id_dataframe ``` ``` -## cluster table_name field indicator spanning_1 spanning_2 spanning_3 hrc_spanning_1 hrc_spanning_2 -## 1 france_entreprises_2023.hrc_lettuce T10.T12.T8 france_entreprises_2023 LETTUCE HRC_NAF cj HRC_LETTUCE^h hrc_naf -## 2 france_entreprises_2023.hrc_lettuce T11.T7.T9 france_entreprises_2023 LETTUCE HRC_NAF size HRC_LETTUCE^h hrc_naf -## 3 france_entreprises_2023.to_pizza T1.T2 france_entreprises_2023 to_pizza HRC_NUTS size hrc_nuts -## 4 france_entreprises_2023.to_pizza T3.T4.T5.T6 france_entreprises_2023 to_pizza HRC_NAF HRC_NUTS hrc_naf hrc_nuts -## hrc_spanning_3 -## 1 hrc_lettuce -## 2 hrc_lettuce -## 3 -## 4 +## cluster table_name field indicator spanning_1 spanning_2 spanning_3 +## 1 france_entreprises_2023.hrc_lettuce T10.T12.T8 france_entreprises_2023 LETTUCE HRC_NAF cj HRC_LETTUCE^h +## 2 france_entreprises_2023.hrc_lettuce T11.T7.T9 france_entreprises_2023 LETTUCE HRC_NAF size HRC_LETTUCE^h +## 3 france_entreprises_2023.to_pizza T1.T2 france_entreprises_2023 to_pizza HRC_NUTS size +## 4 france_entreprises_2023.to_pizza T3.T4.T5.T6 france_entreprises_2023 to_pizza HRC_NAF HRC_NUTS +## hrc_spanning_1 hrc_spanning_2 hrc_spanning_3 +## 1 hrc_naf hrc_lettuce +## 2 hrc_naf hrc_lettuce +## 3 hrc_nuts +## 4 hrc_naf hrc_nuts ``` # Pour aller plus loin : visualiser les inclusions diff --git a/vignettes/auto_metadata_fr.Rmd.orig b/vignettes/auto_metadata_fr.Rmd.orig index b61d857..fbfd382 100644 --- a/vignettes/auto_metadata_fr.Rmd.orig +++ b/vignettes/auto_metadata_fr.Rmd.orig @@ -24,9 +24,9 @@ library(dplyr) # Introduction -Avant de faire appel aux fonctions permettant la pose du secret il est nécessaire d'analyser les tableaux que l'on souhaite protéger. En effet,les tableaux diffusés sont différents des tableaux à protéger. Cela est expliqué en détail au chapitre 3 du [Manuel de protection des tableaux](https://inseefrlab.github.io/manuel-protection-tableaux/03_analyser_une_demande.html). Cette phase d'analyse des marges communes entre les différents tableaux peut s'avérer complexe. Ainsi, des fonctions ont été développées dans `rtauargus` pour faciliter ce travail. +Avant de faire appel aux fonctions permettant la pose du secret il est nécessaire d'analyser les tableaux que l'on souhaite protéger. En effet, les tableaux diffusés sont différents des tableaux à protéger. Cela est expliqué en détail au chapitre 3 du [Manuel de protection des tableaux](https://inseefrlab.github.io/manuel-protection-tableaux/03_analyser_une_demande.html). Cette phase d'analyse des marges communes entre les différents tableaux peut s'avérer complexe. Ainsi, des fonctions ont été développées dans `rtauargus` pour faciliter ce travail. -# Comment fonctionne l'analyse automatique automatique des métadonnées ? +# Comment fonctionne l'analyse automatique des métadonnées ? ## Création des métadonnées \label{sec:crea_meta} Les métadonnées doivent respecter un format spécifique. Une ligne représente un tableau et pour chaque tableau il faut préciser : @@ -106,7 +106,7 @@ On obtient un dataframe nous présentant la façon de traiter les tableaux pour cluster_id_dataframe ``` -Pour les 12 tableaux à publier il suffit de protéger 4 tableaux. Ces tableaux sont repartis dans deux clusters différents. Il faudra donc faire appel deux fois à `tab_multi_manager()`. +Pour les 12 tableaux à publier il suffit de protéger 4 tableaux. Ces tableaux sont répartis dans deux clusters différents. Il faudra donc faire appel deux fois à `tab_multi_manager()`. On remarque une nouvelle variable de croisement `HRC_LETTUCE^h`. Il s'agit d'une variable qui prend pour modalités `batavia` et `arugula` et a pour total `lettuce`. L'indicateur `LETTUCE` renvoie ici au "turnover" (to) ou "chiffre d'affaires" de la vente de salades. Par exemple, le tableau `T10.T12.T8` présente le chiffre d'affaires de la vente de salades en fonction de l'activité et de la catégorie de l'entreprise ainsi que du type de salade. Si l'on souhaite avoir plus d'informations sur l'analyse de la demande, on peut spécifier l'argument `verbose = TRUE`. Ainsi, l'objet renvoyé par la fonction est une liste des différentes étapes de l'analyse. diff --git a/vignettes/logbook.txt b/vignettes/logbook.txt index 0a24b66..98eb2ad 100644 --- a/vignettes/logbook.txt +++ b/vignettes/logbook.txt @@ -188,3 +188,115 @@ 17-févr.-2025 12:15:40 : Table: V2 x V3 | VAL has been written Output file name: C:\Users\KQCFFL\AppData\Local\Temp\Rtmpm05wlj\RTA_13aa836d5f26.sbs 17-févr.-2025 12:15:40 : End of TauArgus run +27-oct.-2026 15:41:08 : Start of batch procedure; file: C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e87f223e1a.arb +27-oct.-2026 15:41:08 : "C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e872ba4592.asc" +27-oct.-2026 15:41:08 : "C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e872ba4592.rda" +27-oct.-2026 15:41:08 : "V1"|""|| +27-oct.-2026 15:41:08 : FREQ(3,10) +27-oct.-2026 15:41:08 : +27-oct.-2026 15:41:08 : Start explore file: C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e872ba4592.asc +27-oct.-2026 15:41:08 : Start computing tables +27-oct.-2026 15:41:08 : Table: V1 | has been specified +27-oct.-2026 15:41:08 : Tables have been computed +27-oct.-2026 15:41:08 : Micro data file read; processing time 0 seconds +27-oct.-2026 15:41:08 : Tables from microdata have been read +27-oct.-2026 15:41:08 : GH(1,100) +27-oct.-2026 15:41:08 : Start of the hypercube protection for table V1 | +27-oct.-2026 15:41:08 : End of hypercube protection. Time used 1 seconds + Number of suppressions: 1 +27-oct.-2026 15:41:08 : The hypercube procedure has been applied + 1 cells have been suppressed +27-oct.-2026 15:41:08 : (1,4,,"C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e87868754c.sbs") +27-oct.-2026 15:41:08 : Table: V1 | has been written + Output file name: C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e87868754c.sbs +27-oct.-2026 15:41:08 : End of TauArgus run +27-oct.-2026 15:41:13 : Start of batch procedure; file: C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e87b4b16fb.arb +27-oct.-2026 15:41:13 : "C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e86746587e.asc" +27-oct.-2026 15:41:13 : "C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e86746587e.rda" +27-oct.-2026 15:41:13 : "V1"|""|| +27-oct.-2026 15:41:13 : FREQ(3,10) +27-oct.-2026 15:41:13 : "V1""V2"|""|| +27-oct.-2026 15:41:13 : FREQ(3,10) +27-oct.-2026 15:41:13 : +27-oct.-2026 15:41:13 : Start explore file: C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e86746587e.asc +27-oct.-2026 15:41:13 : Start computing tables +27-oct.-2026 15:41:13 : Table: V1 | has been specified +27-oct.-2026 15:41:13 : Table: V1 x V2 | has been specified +27-oct.-2026 15:41:13 : Tables have been computed +27-oct.-2026 15:41:13 : Micro data file read; processing time 0 seconds +27-oct.-2026 15:41:13 : Tables from microdata have been read +27-oct.-2026 15:41:13 : GH(1,100) +27-oct.-2026 15:41:13 : Start of the hypercube protection for table V1 | +27-oct.-2026 15:41:13 : End of hypercube protection. Time used 1 seconds + Number of suppressions: 1 +27-oct.-2026 15:41:13 : The hypercube procedure has been applied + 1 cells have been suppressed +27-oct.-2026 15:41:13 : (1,4,,"C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e841576cef.sbs") +27-oct.-2026 15:41:13 : Table: V1 | has been written + Output file name: C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e841576cef.sbs +27-oct.-2026 15:41:13 : GH(2,100) +27-oct.-2026 15:41:13 : Start of the hypercube protection for table V1 x V2 | +27-oct.-2026 15:41:14 : End of hypercube protection. Time used 1 seconds + Number of suppressions: 2 +27-oct.-2026 15:41:14 : The hypercube procedure has been applied + 2 cells have been suppressed +27-oct.-2026 15:41:14 : (2,4,AS+,"C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e841517919.sbs") +27-oct.-2026 15:41:14 : Table: V1 x V2 | has been written + Output file name: C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e841517919.sbs +27-oct.-2026 15:41:14 : End of TauArgus run +27-oct.-2026 15:41:19 : Start of batch procedure; file: Z:\microdata.arb +27-oct.-2026 15:41:19 : "Z:\microdata.asc" +27-oct.-2026 15:41:19 : "Z:\microdata.rda" +27-oct.-2026 15:41:19 : "V1"|""|| +27-oct.-2026 15:41:19 : FREQ(3,10) +27-oct.-2026 15:41:19 : +27-oct.-2026 15:41:19 : Start explore file: Z:\microdata.asc +27-oct.-2026 15:41:19 : Start computing tables +27-oct.-2026 15:41:19 : Table: V1 | has been specified +27-oct.-2026 15:41:19 : Tables have been computed +27-oct.-2026 15:41:19 : Micro data file read; processing time 0 seconds +27-oct.-2026 15:41:19 : Tables from microdata have been read +27-oct.-2026 15:41:19 : GH(1,100) +27-oct.-2026 15:41:19 : Start of the hypercube protection for table V1 | +27-oct.-2026 15:41:19 : End of hypercube protection. Time used 1 seconds + Number of suppressions: 1 +27-oct.-2026 15:41:19 : The hypercube procedure has been applied + 1 cells have been suppressed +27-oct.-2026 15:41:19 : (1,4,,"Z:\results\secretV1.csv") +27-oct.-2026 15:41:19 : Table: V1 | has been written + Output file name: Z:\results\secretV1.csv +27-oct.-2026 15:41:19 : End of TauArgus run +27-oct.-2026 15:43:04 : Start of batch procedure; file: Z:\donnees.arb +27-oct.-2026 15:43:04 : "Z:\donnees.asc" +27-oct.-2026 15:43:04 : "Z:\donnees.rda" +27-oct.-2026 15:43:04 : "V1"|"VAL"|| +27-oct.-2026 15:43:04 : FREQ(3,10)|Wgt(1) +27-oct.-2026 15:43:04 : "V2""V3"|"VAL"|| +27-oct.-2026 15:43:04 : FREQ(3,10)|NK(1,85) +27-oct.-2026 15:43:04 : +27-oct.-2026 15:43:04 : Start explore file: Z:\donnees.asc +27-oct.-2026 15:43:04 : Start computing tables +27-oct.-2026 15:43:04 : Table: V1 | VAL has been specified +27-oct.-2026 15:43:04 : Table: V2 x V3 | VAL has been specified +27-oct.-2026 15:43:04 : Tables have been computed +27-oct.-2026 15:43:04 : Micro data file read; processing time 0 seconds +27-oct.-2026 15:43:04 : Tables from microdata have been read +27-oct.-2026 15:43:04 : GH(1,100) +27-oct.-2026 15:43:04 : Start of the hypercube protection for table V1 | VAL +27-oct.-2026 15:43:04 : End of hypercube protection. Time used 1 seconds + Number of suppressions: 1 +27-oct.-2026 15:43:04 : The hypercube procedure has been applied + 1 cells have been suppressed +27-oct.-2026 15:43:04 : (1,4,AS+SE+,"C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e85ac86a31.sbs") +27-oct.-2026 15:43:04 : Table: V1 | VAL has been written + Output file name: C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e85ac86a31.sbs +27-oct.-2026 15:43:04 : GH(2,100) +27-oct.-2026 15:43:04 : Start of the hypercube protection for table V2 x V3 | VAL +27-oct.-2026 15:43:04 : End of hypercube protection. Time used 1 seconds + Number of suppressions: 2 +27-oct.-2026 15:43:04 : The hypercube procedure has been applied + 2 cells have been suppressed +27-oct.-2026 15:43:04 : (2,4,AS+SE+,"C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e87e4a6f77.sbs") +27-oct.-2026 15:43:04 : Table: V2 x V3 | VAL has been written + Output file name: C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e87e4a6f77.sbs +27-oct.-2026 15:43:05 : End of TauArgus run diff --git a/vignettes/options_safety_rules.Rmd b/vignettes/options_safety_rules.Rmd index ed82209..2d0b391 100644 --- a/vignettes/options_safety_rules.Rmd +++ b/vignettes/options_safety_rules.Rmd @@ -31,7 +31,7 @@ The most common rules are : - The dominance rule **NK(n,k)** with : - n the size of the coalition - k the max percentage -- The treshold rule **Freq(n,p)** with : +- The threshold rule **Freq(n,p)** with : - n the minimum frequency allowed - p the Frequency Safety Range - The p percent rule **P(p,n)** with : @@ -45,7 +45,7 @@ The other ones : - The request rule **REQ(p1,p2,SafetyMargin)** - The zero safety range parameter **ZERO(p)** - The status of missing codes **MIS(b)** with : - - b = 0 (default) cells with a missing code is unsafe if the safety rules ares are violated + - b = 0 (default) cells with a missing code is unsafe if the safety rules are violated - b = 1 these cells are always safe Some rules can appear multiple times **(P,NK)** @@ -94,10 +94,10 @@ More details are available in the τ-Argus manual, especially in the section #### About this vignette - Authors: **Nathanael Rastout** -- Last update: **17/02/2025** -- Version of rtauargus used: **1.2.999** +- Last update: **27/10/2026** +- Version of rtauargus used: **1.3.6** - Version of τ-Argus used : **TauArgus 4.2.3** -- R version used : **4.3.3** +- R version used : **4.5.3**

summary ↑ diff --git a/vignettes/options_safety_rules.Rmd.orig b/vignettes/options_safety_rules.Rmd.orig index 76050fb..e8050df 100644 --- a/vignettes/options_safety_rules.Rmd.orig +++ b/vignettes/options_safety_rules.Rmd.orig @@ -33,7 +33,7 @@ The most common rules are : - The dominance rule **NK(n,k)** with : - n the size of the coalition - k the max percentage -- The treshold rule **Freq(n,p)** with : +- The threshold rule **Freq(n,p)** with : - n the minimum frequency allowed - p the Frequency Safety Range - The p percent rule **P(p,n)** with : @@ -47,7 +47,7 @@ The other ones : - The request rule **REQ(p1,p2,SafetyMargin)** - The zero safety range parameter **ZERO(p)** - The status of missing codes **MIS(b)** with : - - b = 0 (default) cells with a missing code is unsafe if the safety rules ares are violated + - b = 0 (default) cells with a missing code is unsafe if the safety rules are violated - b = 1 these cells are always safe Some rules can appear multiple times **(P,NK)** diff --git a/vignettes/options_safety_rules_fr.Rmd b/vignettes/options_safety_rules_fr.Rmd index fc513f3..effc7bd 100644 --- a/vignettes/options_safety_rules_fr.Rmd +++ b/vignettes/options_safety_rules_fr.Rmd @@ -22,7 +22,7 @@ Si vous voulez définir des règles pour la suppression primaire, la syntaxe est - *"règle_numéro1|règle_numéro2|règle_numéro3|... "*. Au moins une règle de sécurité est requise. -Voci toutes les règles possibles selon le manuel de τ-Argus. +Voici toutes les règles possibles selon le manuel de τ-Argus. Les règles les plus courantes sont : @@ -94,10 +94,10 @@ Plus de détails sont disponibles dans le manuel de τ-Argus, notamment dans #### About this vignette - Authors: **Nathanael Rastout** -- Last update: **17/02/2025** -- Version of rtauargus used: **1.2.999** +- Last update: **27/10/2026** +- Version of rtauargus used: **1.3.6** - Version of τ-Argus used : **TauArgus 4.2.3** -- R version used : **4.3.3** +- R version used : **4.5.3**

summary ↑ diff --git a/vignettes/options_safety_rules_fr.Rmd.orig b/vignettes/options_safety_rules_fr.Rmd.orig index c493bd4..3b8ce1d 100644 --- a/vignettes/options_safety_rules_fr.Rmd.orig +++ b/vignettes/options_safety_rules_fr.Rmd.orig @@ -24,7 +24,7 @@ Si vous voulez définir des règles pour la suppression primaire, la syntaxe est - *"règle_numéro1|règle_numéro2|règle_numéro3|... "*. Au moins une règle de sécurité est requise. -Voci toutes les règles possibles selon le manuel de τ-Argus. +Voici toutes les règles possibles selon le manuel de τ-Argus. Les règles les plus courantes sont : diff --git a/vignettes/protect_multi_tables.Rmd b/vignettes/protect_multi_tables.Rmd index 796b921..122d3ec 100644 --- a/vignettes/protect_multi_tables.Rmd +++ b/vignettes/protect_multi_tables.Rmd @@ -1,651 +1,629 @@ ---- -title: "Protect several linked tables at once" -subtitle:

![logo R](R_logo_small.png)![logo τ-Argus](TauBall2_small.png)
Package {rtauargus}

-output: - rmarkdown::html_vignette: - toc: true - toc_depth: 2 - number_section: true - fig_caption: true -vignette: > - %\VignetteIndexEntry{Protect several tables} - %\VignetteEngine{knitr::rmarkdown} - %\VignetteEncoding{UTF-8} ---- - - - - - -# Introduction - -In `rtauargus` package, it is now possible to protect a set of linked tables at once. -The function to do this is called `tab_multi_manager()`. The very simple algorithm -implemented to handle the protection doesn't depend on the number of tables. Hence, -the function can theoretically deal with an indefinite number of tables. Of course, -the practical use is limited by the power of the computer. However, we are confident -on the ability of the function to treat the most cases. We are interested in cases -that you would encounter and the function can't handle. - - -A link between two (or more) tables describes the common cells of the tables, -that is the cells appearing in them. The function can handle all types of links -between tables: - -- margin links: when two tables share one (or more) variables; -- links between the response variables, when exists some equations connecting the -variables; -- non-nested hierarchies: when an explanatory variable is broken down into two -(or more) non-nested hierarchies. - -Actually, the last two types can be handled as the first one. The challenge for -the user is to properly define the set of the tables. Once the set is correctly -defined, the function takes care of everything. - -Firstly, the vignette will present how the function works, secondly, the parameters -are quickly described. In the third part, some examples are developped to show how -to use it in diverse situations. - - -## How does `tab_multi_manager()` handle the protection of a set of linked tables ? - -Firstly, the function merges all the tables of the set. In the resulted table, boolean -variables are added to mention whether a cell owns to a given table of the set. -So, there are as many boolean variables as the number of tables in the set. -The merged table is a very effective way to quickly detect the common cells. Thus, -the report of the suppressions is automatic. - -The protection process is sequential: one table at a time. To handle the protection -of all the tables and not to forget one table or some links, the implemented algorithm -works with two lists: - -- `todolist`: list of tables which have to be protected; -- `remainlist`: list of original tables which haven't yet been protected at all. - -Both lists are initialized as follows: - -- `todolist` = first table in the original list; -- `remainlist` = all the original tables except the firs one. - -Then, the algorithm proceeds as shown in the following figure: - -How tab_multi_manager's algorithm works - - -## Results - -The function returns the original list of tables with some other variables which -are boolean variables (TRUE if the cell has to be masked, otherwise -FALSE), describing all steps of the suppression process. Each step takes the -previous one into account and the last variable indicates the final step. -Final status of cell is easily computable with this last variable and the -primary suppression status previously computed by the user. - -In addition, the function writes all τ-Argus files created during the process. -At the end, only the last process for each table is available in the chosen directory. -A journal (`journal.txt`) is also provided. It describes each step of the suppression -process: Which table is being protected, how many new common cells have been hit by -secondary suppression. At the end of the process, it provides a description of -all common cells that have been hit, mentionning the iteration of when each has been hit. - - -## Some details on the parameters of `tab_multi_manager()` - -- **dir_name** -the directory that will contain all the created files, if non existing it will be created. -example : dir_name = "my_directory" - -- **hrc** -A named vector specifying the path to the hrc file for each hierarchical variables. -example : c(ACTIVITY = "path_to_file/act.hrc", NUTS = "path_to_file/nuts.hrc" ) - -- **alt_hrc** -A named list useful for dealing with non-nested hierachies. The names of the list -are the names of the tables when alternative (non-nested in general) hierarchies. -example : If T1 and T2 have one explanatory variable, called ACTIVITY, and the -same response variable, but the `ACTIVITY` variable has not the same hierarchy in -the two tables. Let's assume that the hierarchies (act1.hrc and act2.hrc) are not -nested. In that case, we write the two arguments as follows: - - - hrc = c(ACTIVITY = "path_to_file/act_1.hrc"): By default, this hierarchy will - be used. - - alt_hrc = list(T2 = c(ACTIVITY = "path_to_file/act_2.hrc")): In the table T2, - the alternative hierarchy will be used. - -- **totcode** -The code for total for each explanatory variables. It is recommanded to use the -same totcode for each variables. If for example the code is "Total" for all variables. -This syntax is allowed : totcode = "Total" - -Otherwise the expected input is a list specifying the totcode for each explanatory vars. -For example : totcode = list(ACTIVITY = "Total", NUTS = "FR", SIZE ="Ensemble", CJ = "Total") -Default : "Total" - -Warning : If the totals are not in the table, they will be computed by Tau-Argus, but they won't be eligible for primary suppression. We, then, advise users to provide totals -in their tables. - -- **alt_totcode** -A named list for alternative total codes. See `alt_hrc` for use. - -- **value** -The colname of the response variable in the tables, it MUST be the same name for each tables. -For example : value = "turnover" -Default : "value" - -- **freq** -The colname of the frequency variable in the tables, it MUST be the same name for -each tables. -For example : freq = "frequency" -Default : "freq" - -- **secret_var** -The name of the boolean variable specifying primary suppression in the tables, -it MUST be the same name for each tables. -For example : secret_var = "is_secret_prim" -Default : "is_secret_prim" - -- **suppress** -The algorithm required to perform secondary suppression, -explained in the safety_rules vignette. If Modular approach is chosen, after the -first iteration on a given table, the singleton, multi-singleton and minFreq options -are deactivated. -default : MOD(1,5,1,0,0)" - -- **ip_start** -The manual safety range for the first iteration on a table -(integer) -default : 10 - -- **ip_end** -The manual safety range for the second iteration on a table -(integer) -default : 0 - -- **num_iter_max** -This parameter is here to ensure the fact that the function will -stop. -default : 10 - -# Some examples - -Let's specify the location of the TauArgus.exe file in our computer: - - -``` r -options( - rtauargus.tauargus_exe = - "Y:/Logiciels/TauArgus/TauArgus4.2.3/TauArgus.exe" -) -``` - -## About protecting 4 linked tables at once - -In the following example we are going to protect a set of 4 linked tables sharing the same -response variable, that is turnover. - -### Preparing the data - - -``` r -data("turnover_act_size") -data("turnover_act_cj") -data ("turnover_nuts_size") -data("turnover_nuts_cj") -``` - -ACTIVITY X SIZE named turnover_act_size -ACTIVITY X CJ named turnover_act_cj -NUTS X SIZE named turnover_nuts_size -NUTS X CJ named turnover_nuts_cj - - - -``` r -str(turnover_act_size) -#> tibble [414 x 5] (S3: tbl_df/tbl/data.frame) -#> $ ACTIVITY: chr [1:414] "AZ" "BE" "FZ" "GI" ... -#> $ SIZE : chr [1:414] "Total" "Total" "Total" "Total" ... -#> $ N_OBS : int [1:414] 405 12878 28043 62053 8135 8140 11961 41359 26686 25108 ... -#> $ TOT : num [1:414] 44475 24827613 8907311 26962063 8584917 ... -#> $ MAX : num [1:414] 6212 1442029 1065833 3084242 3957364 ... -``` - -``` r -str(turnover_nuts_cj) -#> tibble [452 x 5] (S3: tbl_df/tbl/data.frame) -#> $ NUTS : chr [1:452] "FR10" "FR21" "FR22" "FR23" ... -#> $ CJ : chr [1:452] "Total" "Total" "Total" "Total" ... -#> $ N_OBS: int [1:452] 38462 6769 4561 5090 8611 7811 5643 10411 8179 5163 ... -#> $ TOT : num [1:452] 33026385 2947560 1917663 3701935 5089279 ... -#> $ MAX : num [1:452] 3084242 544763 651848 298134 1165019 ... -``` - -The first step is to create a list containing our four tables, it is advised to -give a name to each tables. By doing so it will be easier to track secondary suppression. - - -``` r -list_data_4_tabs <- list( - act_size = turnover_act_size, - act_cj = turnover_act_cj, - nuts_size = turnover_nuts_size, - nuts_cj = turnover_nuts_cj -) -str(list_data_4_tabs) -#> List of 4 -#> $ act_size : tibble [414 x 5] (S3: tbl_df/tbl/data.frame) -#> ..$ ACTIVITY: chr [1:414] "AZ" "BE" "FZ" "GI" ... -#> ..$ SIZE : chr [1:414] "Total" "Total" "Total" "Total" ... -#> ..$ N_OBS : int [1:414] 405 12878 28043 62053 8135 8140 11961 41359 26686 25108 ... -#> ..$ TOT : num [1:414] 44475 24827613 8907311 26962063 8584917 ... -#> ..$ MAX : num [1:414] 6212 1442029 1065833 3084242 3957364 ... -#> $ act_cj : tibble [406 x 5] (S3: tbl_df/tbl/data.frame) -#> ..$ ACTIVITY: chr [1:406] "AZ" "BE" "FZ" "GI" ... -#> ..$ CJ : chr [1:406] "Total" "Total" "Total" "Total" ... -#> ..$ N_OBS : int [1:406] 405 12878 28043 62053 8135 8140 11961 41359 26686 25108 ... -#> ..$ TOT : num [1:406] 44475 24827613 8907311 26962063 8584917 ... -#> ..$ MAX : num [1:406] 6212 1442029 1065833 3084242 3957364 ... -#> $ nuts_size: tibble [460 x 5] (S3: tbl_df/tbl/data.frame) -#> ..$ NUTS : chr [1:460] "FR10" "FR21" "FR22" "FR23" ... -#> ..$ SIZE : chr [1:460] "Total" "Total" "Total" "Total" ... -#> ..$ N_OBS: int [1:460] 38462 6769 4561 5090 8611 7811 5643 10411 8179 5163 ... -#> ..$ TOT : num [1:460] 33026385 2947560 1917663 3701935 5089279 ... -#> ..$ MAX : num [1:460] 3084242 544763 651848 298134 1165019 ... -#> $ nuts_cj : tibble [452 x 5] (S3: tbl_df/tbl/data.frame) -#> ..$ NUTS : chr [1:452] "FR10" "FR21" "FR22" "FR23" ... -#> ..$ CJ : chr [1:452] "Total" "Total" "Total" "Total" ... -#> ..$ N_OBS: int [1:452] 38462 6769 4561 5090 8611 7811 5643 10411 8179 5163 ... -#> ..$ TOT : num [1:452] 33026385 2947560 1917663 3701935 5089279 ... -#> ..$ MAX : num [1:452] 3084242 544763 651848 298134 1165019 ... -``` - -### Applying primary suppression rules - -Then we need to apply the primary suppression for each table. Here we apply 2 rules : -The dominance rule NK(1,85) and the frequency rule with a threshold set to 3. - - -``` r -list_data_4_tabs <- list_data_4_tabs %>% - purrr::map( - function(df){ - df %>% - mutate( - is_secret_freq = N_OBS > 0 & N_OBS < 3, - is_secret_dom = ifelse(MAX == 0, FALSE, MAX/TOT>0.85), - is_secret_prim = is_secret_freq | is_secret_dom - ) - } - ) -str(list_data_4_tabs) -#> List of 4 -#> $ act_size : tibble [414 x 8] (S3: tbl_df/tbl/data.frame) -#> ..$ ACTIVITY : chr [1:414] "AZ" "BE" "FZ" "GI" ... -#> ..$ SIZE : chr [1:414] "Total" "Total" "Total" "Total" ... -#> ..$ N_OBS : int [1:414] 405 12878 28043 62053 8135 8140 11961 41359 26686 25108 ... -#> ..$ TOT : num [1:414] 44475 24827613 8907311 26962063 8584917 ... -#> ..$ MAX : num [1:414] 6212 1442029 1065833 3084242 3957364 ... -#> ..$ is_secret_freq: logi [1:414] FALSE FALSE FALSE FALSE FALSE FALSE ... -#> ..$ is_secret_dom : logi [1:414] FALSE FALSE FALSE FALSE FALSE FALSE ... -#> ..$ is_secret_prim: logi [1:414] FALSE FALSE FALSE FALSE FALSE FALSE ... -#> $ act_cj : tibble [406 x 8] (S3: tbl_df/tbl/data.frame) -#> ..$ ACTIVITY : chr [1:406] "AZ" "BE" "FZ" "GI" ... -#> ..$ CJ : chr [1:406] "Total" "Total" "Total" "Total" ... -#> ..$ N_OBS : int [1:406] 405 12878 28043 62053 8135 8140 11961 41359 26686 25108 ... -#> ..$ TOT : num [1:406] 44475 24827613 8907311 26962063 8584917 ... -#> ..$ MAX : num [1:406] 6212 1442029 1065833 3084242 3957364 ... -#> ..$ is_secret_freq: logi [1:406] FALSE FALSE FALSE FALSE FALSE FALSE ... -#> ..$ is_secret_dom : logi [1:406] FALSE FALSE FALSE FALSE FALSE FALSE ... -#> ..$ is_secret_prim: logi [1:406] FALSE FALSE FALSE FALSE FALSE FALSE ... -#> $ nuts_size: tibble [460 x 8] (S3: tbl_df/tbl/data.frame) -#> ..$ NUTS : chr [1:460] "FR10" "FR21" "FR22" "FR23" ... -#> ..$ SIZE : chr [1:460] "Total" "Total" "Total" "Total" ... -#> ..$ N_OBS : int [1:460] 38462 6769 4561 5090 8611 7811 5643 10411 8179 5163 ... -#> ..$ TOT : num [1:460] 33026385 2947560 1917663 3701935 5089279 ... -#> ..$ MAX : num [1:460] 3084242 544763 651848 298134 1165019 ... -#> ..$ is_secret_freq: logi [1:460] FALSE FALSE FALSE FALSE FALSE FALSE ... -#> ..$ is_secret_dom : logi [1:460] FALSE FALSE FALSE FALSE FALSE FALSE ... -#> ..$ is_secret_prim: logi [1:460] FALSE FALSE FALSE FALSE FALSE FALSE ... -#> $ nuts_cj : tibble [452 x 8] (S3: tbl_df/tbl/data.frame) -#> ..$ NUTS : chr [1:452] "FR10" "FR21" "FR22" "FR23" ... -#> ..$ CJ : chr [1:452] "Total" "Total" "Total" "Total" ... -#> ..$ N_OBS : int [1:452] 38462 6769 4561 5090 8611 7811 5643 10411 8179 5163 ... -#> ..$ TOT : num [1:452] 33026385 2947560 1917663 3701935 5089279 ... -#> ..$ MAX : num [1:452] 3084242 544763 651848 298134 1165019 ... -#> ..$ is_secret_freq: logi [1:452] FALSE FALSE FALSE FALSE FALSE FALSE ... -#> ..$ is_secret_dom : logi [1:452] FALSE FALSE FALSE FALSE FALSE FALSE ... -#> ..$ is_secret_prim: logi [1:452] FALSE FALSE FALSE FALSE FALSE FALSE ... -``` - -Three variables have been added to each table. Only the last one will be used during -the protection process. The two others will be useful to state the final status of the cells. - -### Preparing the list of explanatory variables - -Then we are going to create the list of explanatory variables of the tables. -In our case, the explanatory variables are the 2 first columns of each table. - - -``` r -nom_var_list <- purrr::map( - list_data_4_tabs, - function(data) colnames(data)[1:2] -) -nom_var_list -#> $act_size -#> [1] "ACTIVITY" "SIZE" -#> -#> $act_cj -#> [1] "ACTIVITY" "CJ" -#> -#> $nuts_size -#> [1] "NUTS" "SIZE" -#> -#> $nuts_cj -#> [1] "NUTS" "CJ" -``` - -The names of the list have to be the names of the corresponding tables in the -`list_tables` argument. - -### Preparing the list of total codes - -The labels used to mention the total for each variable have to declared by the user, -in a named list. However, when all of the variables have the same label to refer -to the total, the information can be mentionned as follows: - - -``` r -total_codes <- "Total" -``` - -### Making the hierarchical files - -`ACTIVITY` and `NUTS` are two hierarchical variables. We use a correspondance table -for each of them to create the `.hrc` files that tau-Argus need. - - -``` r -data(activity_corr_table) -data(nuts23_fr_corr_table) -``` - - -``` r -hrc_file_activity <- write_hrc2( - corr_table = activity_corr_table, - file_name = "hrc/activity.hrc" -) -hrc_file_nuts <- write_hrc2( - corr_table = nuts23_fr_corr_table, - file_name = "hrc/nuts.hrc" -) -``` - -To mention the names of the hrc files, we create a named vector (or list) as follows: - - -``` r -hrc_files <- list( - ACTIVITY = hrc_file_activity, - NUTS = hrc_file_nuts -) -``` - -The names of the vector have to be the names of the corresponding hierarchical -variables. - -### Running the protection of all the tables at once - - -``` r -res <- tab_multi_manager( - list_tables = list_data_4_tabs, - list_explanatory_vars = nom_var_list, - dir_name = "tauargus_files/ex4", - hrc = hrc_files, - totcode = total_codes, - value = "TOT", - freq = "N_OBS", - secret_var = "is_secret_prim" -) -#> --- Current table to treat: act_size --- -#> --- Current table to treat: act_cj --- -#> --- Current table to treat: act_size --- -#> --- Current table to treat: nuts_size --- -#> --- Current table to treat: nuts_cj --- -``` - - -### Results - - -``` r -list_with_status <- res %>% - purrr::map( - function(df){ - df %>% - rename_with(~"final_suppress", last_col()) %>% - mutate( - status = case_when( - is_secret_freq ~ "A", - is_secret_dom ~ "B", - final_suppress ~ "D", - TRUE ~"V" - ) - ) %>% - select(1:2, TOT, N_OBS, status) - } - ) -str(list_with_status$act_size) -#> 'data.frame': 414 obs. of 5 variables: -#> $ ACTIVITY: chr "01" "01" "02" "02" ... -#> $ SIZE : chr "Total" "tr1" "Total" "tr1" ... -#> $ TOT : num 853 853 43623 35503 8120 ... -#> $ N_OBS : int 18 18 387 381 6 1 1 4 4 84 ... -#> $ status : chr "V" "V" "V" "V" ... -``` - - -``` r -list_with_status %>% - purrr::iwalk( - function(df,name){ - cat(name, "\n") - df %>% count(status) %>% print() - } - ) -#> act_size -#> status n -#> 1 A 52 -#> 2 B 25 -#> 3 D 83 -#> 4 V 254 -#> act_cj -#> status n -#> 1 A 35 -#> 2 B 25 -#> 3 D 88 -#> 4 V 258 -#> nuts_size -#> status n -#> 1 A 55 -#> 2 B 17 -#> 3 D 82 -#> 4 V 306 -#> nuts_cj -#> status n -#> 1 A 45 -#> 2 B 20 -#> 3 D 101 -#> 4 V 286 -``` - -## Dealing with non-nested hierarchies - -Let's assume that we'd like to protect the two tables crossing `ACTIVITY` and -`SIZE` in one hand and `ACTIVITY` and `CJ` in the other hand. The `ACTIVITY` variable is a hierarchical one. Moreover, in that case, we'd like to release a subtotal, called `D_TO_M`, in addition to those in the `activity_corr_table`. This subtotal is the sum of the `D` to `M` labels of the `A21` level. As this subtotal can't be inserted in the main hierarchy, this leads us to a case of non-nested hierarchies. - -To confirm the non-nesting of the two hierachies, let's display an extract of both. - -Extract of the main hierarchy: - - -``` r -sdcHierarchies::hier_create( - root="Total", - nodes = activity_corr_table$A10 %>% unique() -) %>% - sdcHierarchies::hier_display() -#> Total -#> +-AZ -#> +-BE -#> +-FZ -#> +-GI -#> +-JZ -#> +-KZ -#> +-LZ -#> +-MN -#> +-OQ -#> \-RU -``` - -Extract of the alternative hierarchy: - - -``` r -sdcHierarchies::hier_create( - root="D_TO_M", - nodes = activity_corr_table_D_TO_M$A21 -) %>% - sdcHierarchies::hier_display() -#> D_TO_M -#> +-D -#> +-E -#> +-F -#> +-G -#> +-H -#> +-I -#> +-J -#> +-K -#> +-L -#> \-M -``` - -To handle this case, the preferred approach is to create a third table crossing -`ACTIVITY` and `SIZE` with D to M labels and the subtotal `D_TO_M`: - - -``` r -turnover_act_size_D_TO_M <- turnover_act_size %>% - filter( - ACTIVITY %in% LETTERS[4:13] - ) %>% - bind_rows( - turnover_act_size %>% - filter( - ACTIVITY %in% LETTERS[4:13] - ) %>% - group_by(SIZE) %>% - summarise(N_OBS = sum(N_OBS), TOT = sum(TOT), MAX = max(MAX)) %>% - mutate(ACTIVITY = "D_TO_M") - ) -str(turnover_act_size_D_TO_M) -#> tibble [44 x 5] (S3: tbl_df/tbl/data.frame) -#> $ ACTIVITY: chr [1:44] "D" "E" "F" "G" ... -#> $ SIZE : chr [1:44] "Total" "Total" "Total" "Total" ... -#> $ N_OBS : int [1:44] 1411 828 28043 41624 6524 13905 8135 8140 11961 28221 ... -#> $ TOT : num [1:44] 2438454 2264393 8907311 18244309 6273334 ... -#> $ MAX : num [1:44] 981369 306905 1065833 765244 3084242 ... -``` - -Let's create the alternative hierarchy file. - - -``` r -activity_corr_table_D_TO_M <- activity_corr_table %>% - filter(A21 %in% LETTERS[4:13]) %>% - select(-A88) %>% - mutate(A10 = "D_TO_M") %>% - unique() - -hrc_file_activity_D_TO_M <- activity_corr_table_D_TO_M %>% - select(-1) %>% - write_hrc2(file_name = "hrc/activity_D_TO_M") -``` - -Then, let's build the list of tables and apply the primary suppression rules -on them. - - -``` r -list_data_3_tabs_nn <- list( - act_size = turnover_act_size, - act_size_D_TO_M = turnover_act_size_D_TO_M, - act_cj = turnover_act_cj -) %>% - purrr::map( - function(df){ - df %>% - mutate( - is_secret_freq = N_OBS > 0 & N_OBS < 3, - is_secret_dom = ifelse(MAX == 0, FALSE, MAX/TOT>0.85), - is_secret_prim = is_secret_freq | is_secret_dom - ) - } - ) -``` - -The `hrc` and `alt_hrc` arguments are used to mention both hierarchies of the `ACTIVITY` variable: - -- `hrc` is used as int the previous example (a named vector where names are the different hierarchical variables appearingin the tables and values are the files names). Hence, the hierarchy file will be taken in this vector by default. -- `alt_hrc` is only used to mention the alternative hierarchies. This argument is a named list where names are the tables where the alternative hierarchies have to be applied. - -The same rationale is used to fill the `alt_totcode` argument. - - -``` r -res <- tab_multi_manager( - list_tables = list_data_3_tabs_nn, - list_explanatory_vars = list( - act_size = c("ACTIVITY", "SIZE"), - act_size_D_TO_M = c("ACTIVITY", "SIZE"), - act_cj = c("ACTIVITY", "CJ") - ), - hrc = c(ACTIVITY = hrc_file_activity), - alt_hrc = list( - act_size_D_TO_M = c(ACTIVITY = hrc_file_activity_D_TO_M) - ), - dir_name = "tauargus_files/ex5", - value = "TOT", - freq = "N_OBS", - secret_var = "is_secret_prim", - totcode = "Total", - alt_totcode = list( - act_size_D_TO_M = c(ACTIVITY = "D_TO_M") - ) -) -#> --- Current table to treat: act_size --- -#> --- Current table to treat: act_size_D_TO_M --- -#> --- Current table to treat: act_cj --- -#> --- Current table to treat: act_size --- -#> --- Current table to treat: act_size_D_TO_M --- -#> --- Current table to treat: act_size --- -#> --- Current table to treat: act_cj --- -``` - -#### About this vignette - -- Authors: **Julien Jamme** & **Nathanael Rastout** -- Last update: **17/02/2025** -- Version of rtauargus used: **1.2.999** -- Version of τ-Argus used : **TauArgus 4.2.3** -- R version used : **4.3.3** - -

- summary ↑ -

+--- +title: "Protect several linked tables at once" +subtitle:

![logo R](R_logo_small.png)![logo τ-Argus](TauBall2_small.png)
Package {rtauargus}

+output: + rmarkdown::html_vignette: + toc: true + toc_depth: 2 + number_section: true + fig_caption: true +vignette: > + %\VignetteIndexEntry{Protect several tables} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + + + + + +# Introduction + +In `rtauargus` package, it is now possible to protect a set of linked tables at once. +The function to do this is called `tab_multi_manager()`. The very simple algorithm +implemented to handle the protection doesn't depend on the number of tables. Hence, +the function can theoretically deal with an indefinite number of tables. Of course, +the practical use is limited by the power of the computer. However, we are confident +on the ability of the function to treat the most cases. We are interested in cases +that you would encounter and the function can't handle. + + +A link between two (or more) tables describes the common cells of the tables, +that is the cells appearing in them. The function can handle all types of links +between tables: + +- margin links: when two tables share one (or more) variables; +- links between the response variables, when exists some equations connecting the +variables; +- non-nested hierarchies: when an explanatory variable is broken down into two +(or more) non-nested hierarchies. + +Actually, the last two types can be handled as the first one. The challenge for +the user is to properly define the set of the tables. Once the set is correctly +defined, the function takes care of everything. + +Firstly, the vignette will present how the function works, secondly, the parameters +are quickly described. In the third part, some examples are developed to show how +to use it in diverse situations. + + +## How does `tab_multi_manager()` handle the protection of a set of linked tables ? + +Firstly, the function merges all the tables of the set. In the resulted table, boolean +variables are added to mention whether a cell owns to a given table of the set. +So, there are as many boolean variables as the number of tables in the set. +The merged table is a very effective way to quickly detect the common cells. Thus, +the report of the suppressions is automatic. + +The protection process is sequential: one table at a time. To handle the protection +of all the tables and not to forget one table or some links, the implemented algorithm +works with two lists: + +- `todolist`: list of tables which have to be protected; +- `remainlist`: list of original tables which haven't yet been protected at all. + +Both lists are initialized as follows: + +- `todolist` = first table in the original list; +- `remainlist` = all the original tables except the first one. + +Then, the algorithm proceeds as shown in the following figure: + +How tab_multi_manager's algorithm works + + +## Results + +The function returns the original list of tables with some other variables which +are boolean variables (TRUE if the cell has to be masked, otherwise +FALSE), describing all steps of the suppression process. Each step takes the +previous one into account and the last variable indicates the final step. +Final status of cell is easily computable with this last variable and the +primary suppression status previously computed by the user. + +In addition, the function writes all τ-Argus files created during the process. +At the end, only the last process for each table is available in the chosen directory. +A journal (`journal.txt`) is also provided. It describes each step of the suppression +process: Which table is being protected, how many new common cells have been hit by +secondary suppression. At the end of the process, it provides a description of +all common cells that have been hit, mentioning the iteration of when each has been hit. + + +## Some details on the parameters of `tab_multi_manager()` + +- **dir_name** +the directory that will contain all the created files, if non existing it will be created. +example : dir_name = "my_directory" + +- **hrc** +A named vector specifying the path to the hrc file for each hierarchical variables. +example : c(ACTIVITY = "path_to_file/act.hrc", NUTS = "path_to_file/nuts.hrc" ) + +- **alt_hrc** +A named list useful for dealing with non-nested hierarchies. The names of the list +are the names of the tables when alternative (non-nested in general) hierarchies. +example : If T1 and T2 have one explanatory variable, called ACTIVITY, and the +same response variable, but the `ACTIVITY` variable has not the same hierarchy in +the two tables. Let's assume that the hierarchies (act1.hrc and act2.hrc) are not +nested. In that case, we write the two arguments as follows: + + - hrc = c(ACTIVITY = "path_to_file/act_1.hrc"): By default, this hierarchy will + be used. + - alt_hrc = list(T2 = c(ACTIVITY = "path_to_file/act_2.hrc")): In the table T2, + the alternative hierarchy will be used. + +- **totcode** +The code for total for each explanatory variables. It is recommended to use the +same totcode for each variables. If for example the code is "Total" for all variables. +This syntax is allowed : totcode = "Total" + +Otherwise the expected input is a list specifying the totcode for each explanatory vars. +For example : totcode = list(ACTIVITY = "Total", NUTS = "FR", SIZE ="Ensemble", CJ = "Total") +Default : "Total" + +Warning : If the totals are not in the table, they will be computed by Tau-Argus, but they won't be eligible for primary suppression. We, then, advise users to provide totals +in their tables. + +- **alt_totcode** +A named list for alternative total codes. See `alt_hrc` for use. + +- **value** +The colname of the response variable in the tables, it MUST be the same name for each tables. +For example : value = "turnover" +Default : "value" + +- **freq** +The colname of the frequency variable in the tables, it MUST be the same name for +each tables. +For example : freq = "frequency" +Default : "freq" + +- **secret_var** +The name of the boolean variable specifying primary suppression in the tables, +it MUST be the same name for each tables. +For example : secret_var = "is_secret_prim" +Default : "is_secret_prim" + +- **suppress** +The algorithm required to perform secondary suppression, +explained in the safety_rules vignette. If Modular approach is chosen, after the +first iteration on a given table, the singleton, multi-singleton and minFreq options +are deactivated. +default : MOD(1,5,1,0,0)" + +- **ip_start** +The manual safety range for the first iteration on a table +(integer) +default : 10 + +- **ip_end** +The manual safety range for the second iteration on a table +(integer) +default : 0 + +- **num_iter_max** +This parameter is here to ensure the fact that the function will +stop. +default : 10 + +# Some examples + +Let's specify the location of the TauArgus.exe file in our computer: + + +``` r +options( + rtauargus.tauargus_exe = + "Y:/Logiciels/TauArgus/TauArgus4.2.3/TauArgus.exe" +) +``` + +## About protecting 4 linked tables at once + +In the following example we are going to protect a set of 4 linked tables sharing the same +response variable, that is turnover. + +### Preparing the data + + +``` r +data("turnover_act_size") +data("turnover_act_cj") +data ("turnover_nuts_size") +data("turnover_nuts_cj") +``` + +ACTIVITY X SIZE named turnover_act_size +ACTIVITY X CJ named turnover_act_cj +NUTS X SIZE named turnover_nuts_size +NUTS X CJ named turnover_nuts_cj + + + +``` r +str(turnover_act_size) +#> tibble [414 x 5] (S3: tbl_df/tbl/data.frame) +#> $ ACTIVITY: chr [1:414] "AZ" "BE" "FZ" "GI" ... +#> $ SIZE : chr [1:414] "Total" "Total" "Total" "Total" ... +#> $ N_OBS : int [1:414] 405 12878 28043 62053 8135 8140 11961 41359 26686 25108 ... +#> $ TOT : num [1:414] 44475 24827613 8907311 26962063 8584917 ... +#> $ MAX : num [1:414] 6212 1442029 1065833 3084242 3957364 ... +str(turnover_nuts_cj) +#> tibble [452 x 5] (S3: tbl_df/tbl/data.frame) +#> $ NUTS : chr [1:452] "FR10" "FR21" "FR22" "FR23" ... +#> $ CJ : chr [1:452] "Total" "Total" "Total" "Total" ... +#> $ N_OBS: int [1:452] 38462 6769 4561 5090 8611 7811 5643 10411 8179 5163 ... +#> $ TOT : num [1:452] 33026385 2947560 1917663 3701935 5089279 ... +#> $ MAX : num [1:452] 3084242 544763 651848 298134 1165019 ... +``` + +The first step is to create a list containing our four tables, it is advised to +give a name to each tables. By doing so it will be easier to track secondary suppression. + + +``` r +list_data_4_tabs <- list( + act_size = turnover_act_size, + act_cj = turnover_act_cj, + nuts_size = turnover_nuts_size, + nuts_cj = turnover_nuts_cj +) +str(list_data_4_tabs) +#> List of 4 +#> $ act_size : tibble [414 x 5] (S3: tbl_df/tbl/data.frame) +#> ..$ ACTIVITY: chr [1:414] "AZ" "BE" "FZ" "GI" ... +#> ..$ SIZE : chr [1:414] "Total" "Total" "Total" "Total" ... +#> ..$ N_OBS : int [1:414] 405 12878 28043 62053 8135 8140 11961 41359 26686 25108 ... +#> ..$ TOT : num [1:414] 44475 24827613 8907311 26962063 8584917 ... +#> ..$ MAX : num [1:414] 6212 1442029 1065833 3084242 3957364 ... +#> $ act_cj : tibble [406 x 5] (S3: tbl_df/tbl/data.frame) +#> ..$ ACTIVITY: chr [1:406] "AZ" "BE" "FZ" "GI" ... +#> ..$ CJ : chr [1:406] "Total" "Total" "Total" "Total" ... +#> ..$ N_OBS : int [1:406] 405 12878 28043 62053 8135 8140 11961 41359 26686 25108 ... +#> ..$ TOT : num [1:406] 44475 24827613 8907311 26962063 8584917 ... +#> ..$ MAX : num [1:406] 6212 1442029 1065833 3084242 3957364 ... +#> $ nuts_size: tibble [460 x 5] (S3: tbl_df/tbl/data.frame) +#> ..$ NUTS : chr [1:460] "FR10" "FR21" "FR22" "FR23" ... +#> ..$ SIZE : chr [1:460] "Total" "Total" "Total" "Total" ... +#> ..$ N_OBS: int [1:460] 38462 6769 4561 5090 8611 7811 5643 10411 8179 5163 ... +#> ..$ TOT : num [1:460] 33026385 2947560 1917663 3701935 5089279 ... +#> ..$ MAX : num [1:460] 3084242 544763 651848 298134 1165019 ... +#> $ nuts_cj : tibble [452 x 5] (S3: tbl_df/tbl/data.frame) +#> ..$ NUTS : chr [1:452] "FR10" "FR21" "FR22" "FR23" ... +#> ..$ CJ : chr [1:452] "Total" "Total" "Total" "Total" ... +#> ..$ N_OBS: int [1:452] 38462 6769 4561 5090 8611 7811 5643 10411 8179 5163 ... +#> ..$ TOT : num [1:452] 33026385 2947560 1917663 3701935 5089279 ... +#> ..$ MAX : num [1:452] 3084242 544763 651848 298134 1165019 ... +``` + +### Applying primary suppression rules + +Then we need to apply the primary suppression for each table. Here we apply 2 rules : +The dominance rule NK(1,85) and the frequency rule with a threshold set to 3. + + +``` r +list_data_4_tabs <- list_data_4_tabs %>% + purrr::map( + function(df){ + df %>% + mutate( + is_secret_freq = N_OBS > 0 & N_OBS < 3, + is_secret_dom = ifelse(MAX == 0, FALSE, MAX/TOT>0.85), + is_secret_prim = is_secret_freq | is_secret_dom + ) + } + ) +str(list_data_4_tabs) +#> List of 4 +#> $ act_size : tibble [414 x 8] (S3: tbl_df/tbl/data.frame) +#> ..$ ACTIVITY : chr [1:414] "AZ" "BE" "FZ" "GI" ... +#> ..$ SIZE : chr [1:414] "Total" "Total" "Total" "Total" ... +#> ..$ N_OBS : int [1:414] 405 12878 28043 62053 8135 8140 11961 41359 26686 25108 ... +#> ..$ TOT : num [1:414] 44475 24827613 8907311 26962063 8584917 ... +#> ..$ MAX : num [1:414] 6212 1442029 1065833 3084242 3957364 ... +#> ..$ is_secret_freq: logi [1:414] FALSE FALSE FALSE FALSE FALSE FALSE ... +#> ..$ is_secret_dom : logi [1:414] FALSE FALSE FALSE FALSE FALSE FALSE ... +#> ..$ is_secret_prim: logi [1:414] FALSE FALSE FALSE FALSE FALSE FALSE ... +#> $ act_cj : tibble [406 x 8] (S3: tbl_df/tbl/data.frame) +#> ..$ ACTIVITY : chr [1:406] "AZ" "BE" "FZ" "GI" ... +#> ..$ CJ : chr [1:406] "Total" "Total" "Total" "Total" ... +#> ..$ N_OBS : int [1:406] 405 12878 28043 62053 8135 8140 11961 41359 26686 25108 ... +#> ..$ TOT : num [1:406] 44475 24827613 8907311 26962063 8584917 ... +#> ..$ MAX : num [1:406] 6212 1442029 1065833 3084242 3957364 ... +#> ..$ is_secret_freq: logi [1:406] FALSE FALSE FALSE FALSE FALSE FALSE ... +#> ..$ is_secret_dom : logi [1:406] FALSE FALSE FALSE FALSE FALSE FALSE ... +#> ..$ is_secret_prim: logi [1:406] FALSE FALSE FALSE FALSE FALSE FALSE ... +#> $ nuts_size: tibble [460 x 8] (S3: tbl_df/tbl/data.frame) +#> ..$ NUTS : chr [1:460] "FR10" "FR21" "FR22" "FR23" ... +#> ..$ SIZE : chr [1:460] "Total" "Total" "Total" "Total" ... +#> ..$ N_OBS : int [1:460] 38462 6769 4561 5090 8611 7811 5643 10411 8179 5163 ... +#> ..$ TOT : num [1:460] 33026385 2947560 1917663 3701935 5089279 ... +#> ..$ MAX : num [1:460] 3084242 544763 651848 298134 1165019 ... +#> ..$ is_secret_freq: logi [1:460] FALSE FALSE FALSE FALSE FALSE FALSE ... +#> ..$ is_secret_dom : logi [1:460] FALSE FALSE FALSE FALSE FALSE FALSE ... +#> ..$ is_secret_prim: logi [1:460] FALSE FALSE FALSE FALSE FALSE FALSE ... +#> $ nuts_cj : tibble [452 x 8] (S3: tbl_df/tbl/data.frame) +#> ..$ NUTS : chr [1:452] "FR10" "FR21" "FR22" "FR23" ... +#> ..$ CJ : chr [1:452] "Total" "Total" "Total" "Total" ... +#> ..$ N_OBS : int [1:452] 38462 6769 4561 5090 8611 7811 5643 10411 8179 5163 ... +#> ..$ TOT : num [1:452] 33026385 2947560 1917663 3701935 5089279 ... +#> ..$ MAX : num [1:452] 3084242 544763 651848 298134 1165019 ... +#> ..$ is_secret_freq: logi [1:452] FALSE FALSE FALSE FALSE FALSE FALSE ... +#> ..$ is_secret_dom : logi [1:452] FALSE FALSE FALSE FALSE FALSE FALSE ... +#> ..$ is_secret_prim: logi [1:452] FALSE FALSE FALSE FALSE FALSE FALSE ... +``` + +Three variables have been added to each table. Only the last one will be used during +the protection process. The two others will be useful to state the final status of the cells. + +### Preparing the list of explanatory variables + +Then we are going to create the list of explanatory variables of the tables. +In our case, the explanatory variables are the 2 first columns of each table. + + +``` r +nom_var_list <- purrr::map( + list_data_4_tabs, + function(data) colnames(data)[1:2] +) +nom_var_list +#> $act_size +#> [1] "ACTIVITY" "SIZE" +#> +#> $act_cj +#> [1] "ACTIVITY" "CJ" +#> +#> $nuts_size +#> [1] "NUTS" "SIZE" +#> +#> $nuts_cj +#> [1] "NUTS" "CJ" +``` + +The names of the list have to be the names of the corresponding tables in the +`list_tables` argument. + +### Preparing the list of total codes + +The labels used to mention the total for each variable have to declared by the user, +in a named list. However, when all of the variables have the same label to refer +to the total, the information can be mentioned as follows: + + +``` r +total_codes <- "Total" +``` + +### Making the hierarchical files + +`ACTIVITY` and `NUTS` are two hierarchical variables. We use a correspondance table +for each of them to create the `.hrc` files that tau-Argus need. + + +``` r +data(activity_corr_table) +data(nuts23_fr_corr_table) +``` + + +``` r +hrc_file_activity <- write_hrc2( + corr_table = activity_corr_table, + file_name = "hrc/activity.hrc" +) +hrc_file_nuts <- write_hrc2( + corr_table = nuts23_fr_corr_table, + file_name = "hrc/nuts.hrc" +) +``` + +To mention the names of the hrc files, we create a named vector (or list) as follows: + + +``` r +hrc_files <- list( + ACTIVITY = hrc_file_activity, + NUTS = hrc_file_nuts +) +``` + +The names of the vector have to be the names of the corresponding hierarchical +variables. + +### Running the protection of all the tables at once + + +``` r +res <- tab_multi_manager( + list_tables = list_data_4_tabs, + list_explanatory_vars = nom_var_list, + dir_name = "tauargus_files/ex4", + hrc = hrc_files, + totcode = total_codes, + value = "TOT", + freq = "N_OBS", + secret_var = "is_secret_prim" +) +#> --- Current table to treat: act_size | loop iter : 1 --- --- Current table to treat: act_cj | loop iter : 2 --- --- Current table to treat: act_size | loop iter : 3 --- --- Current table to treat: nuts_size | loop iter : 4 --- --- Current table to treat: nuts_cj | loop iter : 5 --- +``` + + +### Results + + +``` r +list_with_status <- res %>% + purrr::map( + function(df){ + df %>% + rename_with(~"final_suppress", last_col()) %>% + mutate( + status = case_when( + is_secret_freq ~ "A", + is_secret_dom ~ "B", + final_suppress ~ "D", + TRUE ~"V" + ) + ) %>% + select(1:2, TOT, N_OBS, status) + } + ) +str(list_with_status$act_size) +#> 'data.frame': 414 obs. of 5 variables: +#> $ ACTIVITY: chr "01" "01" "02" "02" ... +#> $ SIZE : chr "Total" "tr1" "Total" "tr1" ... +#> $ TOT : num 853 853 43623 35503 8120 ... +#> $ N_OBS : int 18 18 387 381 6 1 1 4 4 84 ... +#> $ status : chr "V" "V" "V" "V" ... +``` + + +``` r +list_with_status %>% + purrr::iwalk( + function(df,name){ + cat(name, "\n") + df %>% count(status) %>% print() + } + ) +#> act_size +#> status n +#> 1 A 52 +#> 2 B 25 +#> 3 D 83 +#> 4 V 254 +#> act_cj +#> status n +#> 1 A 35 +#> 2 B 25 +#> 3 D 88 +#> 4 V 258 +#> nuts_size +#> status n +#> 1 A 55 +#> 2 B 17 +#> 3 D 82 +#> 4 V 306 +#> nuts_cj +#> status n +#> 1 A 45 +#> 2 B 20 +#> 3 D 101 +#> 4 V 286 +``` + +## Dealing with non-nested hierarchies + +Let's assume that we'd like to protect the two tables crossing `ACTIVITY` and +`SIZE` in one hand and `ACTIVITY` and `CJ` in the other hand. The `ACTIVITY` variable is a hierarchical one. Moreover, in that case, we'd like to release a subtotal, called `D_TO_M`, in addition to those in the `activity_corr_table`. This subtotal is the sum of the `D` to `M` labels of the `A21` level. As this subtotal can't be inserted in the main hierarchy, this leads us to a case of non-nested hierarchies. + +To confirm the non-nesting of the two hierarchies, let's display an extract of both. + +Extract of the main hierarchy: + + +``` r +sdcHierarchies::hier_create( + root="Total", + nodes = activity_corr_table$A10 %>% unique() +) %>% + sdcHierarchies::hier_display() +#> Total +#> +-AZ +#> +-BE +#> +-FZ +#> +-GI +#> +-JZ +#> +-KZ +#> +-LZ +#> +-MN +#> +-OQ +#> \-RU +``` + +Extract of the alternative hierarchy: + + +``` r +sdcHierarchies::hier_create( + root="D_TO_M", + nodes = activity_corr_table_D_TO_M$A21 +) %>% + sdcHierarchies::hier_display() +#> Error: +#> ! objet 'activity_corr_table_D_TO_M' introuvable +``` + +To handle this case, the preferred approach is to create a third table crossing +`ACTIVITY` and `SIZE` with D to M labels and the subtotal `D_TO_M`: + + +``` r +turnover_act_size_D_TO_M <- turnover_act_size %>% + filter( + ACTIVITY %in% LETTERS[4:13] + ) %>% + bind_rows( + turnover_act_size %>% + filter( + ACTIVITY %in% LETTERS[4:13] + ) %>% + group_by(SIZE) %>% + summarise(N_OBS = sum(N_OBS), TOT = sum(TOT), MAX = max(MAX)) %>% + mutate(ACTIVITY = "D_TO_M") + ) +str(turnover_act_size_D_TO_M) +#> tibble [44 x 5] (S3: tbl_df/tbl/data.frame) +#> $ ACTIVITY: chr [1:44] "D" "E" "F" "G" ... +#> $ SIZE : chr [1:44] "Total" "Total" "Total" "Total" ... +#> $ N_OBS : int [1:44] 1411 828 28043 41624 6524 13905 8135 8140 11961 28221 ... +#> $ TOT : num [1:44] 2438454 2264393 8907311 18244309 6273334 ... +#> $ MAX : num [1:44] 981369 306905 1065833 765244 3084242 ... +``` + +Let's create the alternative hierarchy file. + + +``` r +activity_corr_table_D_TO_M <- activity_corr_table %>% + filter(A21 %in% LETTERS[4:13]) %>% + select(-A88) %>% + mutate(A10 = "D_TO_M") %>% + unique() + +hrc_file_activity_D_TO_M <- activity_corr_table_D_TO_M %>% + select(-1) %>% + write_hrc2(file_name = "hrc/activity_D_TO_M") +``` + +Then, let's build the list of tables and apply the primary suppression rules +on them. + + +``` r +list_data_3_tabs_nn <- list( + act_size = turnover_act_size, + act_size_D_TO_M = turnover_act_size_D_TO_M, + act_cj = turnover_act_cj +) %>% + purrr::map( + function(df){ + df %>% + mutate( + is_secret_freq = N_OBS > 0 & N_OBS < 3, + is_secret_dom = ifelse(MAX == 0, FALSE, MAX/TOT>0.85), + is_secret_prim = is_secret_freq | is_secret_dom + ) + } + ) +``` + +The `hrc` and `alt_hrc` arguments are used to mention both hierarchies of the `ACTIVITY` variable: + +- `hrc` is used as in the previous example (a named vector where names are the different hierarchical variables appearing in the tables and values are the files names). Hence, the hierarchy file will be taken in this vector by default. +- `alt_hrc` is only used to mention the alternative hierarchies. This argument is a named list where names are the tables where the alternative hierarchies have to be applied. + +The same rationale is used to fill the `alt_totcode` argument. + + +``` r +res <- tab_multi_manager( + list_tables = list_data_3_tabs_nn, + list_explanatory_vars = list( + act_size = c("ACTIVITY", "SIZE"), + act_size_D_TO_M = c("ACTIVITY", "SIZE"), + act_cj = c("ACTIVITY", "CJ") + ), + hrc = c(ACTIVITY = hrc_file_activity), + alt_hrc = list( + act_size_D_TO_M = c(ACTIVITY = hrc_file_activity_D_TO_M) + ), + dir_name = "tauargus_files/ex5", + value = "TOT", + freq = "N_OBS", + secret_var = "is_secret_prim", + totcode = "Total", + alt_totcode = list( + act_size_D_TO_M = c(ACTIVITY = "D_TO_M") + ) +) +#> --- Current table to treat: act_size | loop iter : 1 --- --- Current table to treat: act_size_D_TO_M | loop iter : 2 --- --- Current table to treat: act_cj | loop iter : 3 --- --- Current table to treat: act_size | loop iter : 4 --- --- Current table to treat: act_size_D_TO_M | loop iter : 5 --- --- Current table to treat: act_size | loop iter : 6 --- --- Current table to treat: act_cj | loop iter : 7 --- +``` + +#### About this vignette + +- Authors: **Julien Jamme** & **Nathanael Rastout** +- Last update: **27/10/2026** +- Version of rtauargus used: **1.3.6** +- Version of τ-Argus used : **TauArgus 4.2.3** +- R version used : **4.5.3** + +

+ summary ↑ +

diff --git a/vignettes/protect_multi_tables.Rmd.orig b/vignettes/protect_multi_tables.Rmd.orig index f01047a..2fb1977 100644 --- a/vignettes/protect_multi_tables.Rmd.orig +++ b/vignettes/protect_multi_tables.Rmd.orig @@ -55,7 +55,7 @@ the user is to properly define the set of the tables. Once the set is correctly defined, the function takes care of everything. Firstly, the vignette will present how the function works, secondly, the parameters -are quickly described. In the third part, some examples are developped to show how +are quickly described. In the third part, some examples are developed to show how to use it in diverse situations. @@ -77,7 +77,7 @@ works with two lists: Both lists are initialized as follows: - `todolist` = first table in the original list; -- `remainlist` = all the original tables except the firs one. +- `remainlist` = all the original tables except the first one. Then, the algorithm proceeds as shown in the following figure: @@ -98,7 +98,7 @@ At the end, only the last process for each table is available in the chosen dire A journal (`journal.txt`) is also provided. It describes each step of the suppression process: Which table is being protected, how many new common cells have been hit by secondary suppression. At the end of the process, it provides a description of -all common cells that have been hit, mentionning the iteration of when each has been hit. +all common cells that have been hit, mentioning the iteration of when each has been hit. ## Some details on the parameters of `tab_multi_manager()` @@ -112,7 +112,7 @@ A named vector specifying the path to the hrc file for each hierarchical variabl example : c(ACTIVITY = "path_to_file/act.hrc", NUTS = "path_to_file/nuts.hrc" ) - **alt_hrc** -A named list useful for dealing with non-nested hierachies. The names of the list +A named list useful for dealing with non-nested hierarchies. The names of the list are the names of the tables when alternative (non-nested in general) hierarchies. example : If T1 and T2 have one explanatory variable, called ACTIVITY, and the same response variable, but the `ACTIVITY` variable has not the same hierarchy in @@ -125,7 +125,7 @@ nested. In that case, we write the two arguments as follows: the alternative hierarchy will be used. - **totcode** -The code for total for each explanatory variables. It is recommanded to use the +The code for total for each explanatory variables. It is recommended to use the same totcode for each variables. If for example the code is "Total" for all variables. This syntax is allowed : totcode = "Total" @@ -270,7 +270,7 @@ The names of the list have to be the names of the corresponding tables in the The labels used to mention the total for each variable have to declared by the user, in a named list. However, when all of the variables have the same label to refer -to the total, the information can be mentionned as follows: +to the total, the information can be mentioned as follows: ```{r totcodes} total_codes <- "Total" @@ -362,7 +362,7 @@ list_with_status %>% Let's assume that we'd like to protect the two tables crossing `ACTIVITY` and `SIZE` in one hand and `ACTIVITY` and `CJ` in the other hand. The `ACTIVITY` variable is a hierarchical one. Moreover, in that case, we'd like to release a subtotal, called `D_TO_M`, in addition to those in the `activity_corr_table`. This subtotal is the sum of the `D` to `M` labels of the `A21` level. As this subtotal can't be inserted in the main hierarchy, this leads us to a case of non-nested hierarchies. -To confirm the non-nesting of the two hierachies, let's display an extract of both. +To confirm the non-nesting of the two hierarchies, let's display an extract of both. Extract of the main hierarchy: @@ -441,7 +441,7 @@ list_data_3_tabs_nn <- list( The `hrc` and `alt_hrc` arguments are used to mention both hierarchies of the `ACTIVITY` variable: -- `hrc` is used as int the previous example (a named vector where names are the different hierarchical variables appearingin the tables and values are the files names). Hence, the hierarchy file will be taken in this vector by default. +- `hrc` is used as in the previous example (a named vector where names are the different hierarchical variables appearing in the tables and values are the files names). Hence, the hierarchy file will be taken in this vector by default. - `alt_hrc` is only used to mention the alternative hierarchies. This argument is a named list where names are the tables where the alternative hierarchies have to be applied. The same rationale is used to fill the `alt_totcode` argument. diff --git a/vignettes/protect_multi_tables_fr.Rmd b/vignettes/protect_multi_tables_fr.Rmd index aa84b55..7ef5f15 100644 --- a/vignettes/protect_multi_tables_fr.Rmd +++ b/vignettes/protect_multi_tables_fr.Rmd @@ -1,668 +1,655 @@ ---- -title: "Protéger des tableaux liés" -subtitle:

![logo R](R_logo_small.png)![logo τ-Argus](TauBall2_small.png)
Package {rtauargus}

-output: - rmarkdown::html_vignette: - toc: true - toc_depth: 2 - number_section: true - fig_caption: true -vignette: > - %\VignetteIndexEntry{Protéger des tableaux liés} - %\VignetteEngine{knitr::rmarkdown} - %\VignetteEncoding{UTF-8} ---- - - - - - -# Introduction - -Dans le package `rtauargus`, il est maintenant possible de protéger un ensemble -de tableaux liés en une seule fois. La fonction pour le faire s'appelle -`tab_multi_manager()`. L'algorithme très simple implémenté pour gérer la protection -ne dépend pas du nombre de tableaux. Par conséquent,la fonction peut théoriquement -traiter un nombre indéfini de tableaux. Bien sûr, l'utilisation pratique est limitée -par la puissance de l'ordinateur. Cependant, nous sommes confiants sur la capacité -de la fonction à traiter la plupart des cas. Nous sommes intéressés par les cas que -vous pourriez rencontrer et que la fonction ne peut pas traiter. - -Un lien entre deux (ou plusieurs) tableaux décrit les cellules communes des tableaux, -c'est-à-dire les cellules qui sont présentent dans ces derniers. -La fonction peut gérer tous les types de liens entre tableaux : - -- les marges communes : lorsque deux tableaux partagent une (ou plusieurs) -variables de ventilation ; -- liens entre les variables de réponse, lorsqu'il existe des équations reliant -les variables ; -- hiérarchies non emboitées : lorsqu'une variable explicative est décomposée en -deux (ou plus) hiérarchies non emboitées. - -En fait, les deux derniers types peuvent être traités comme le premier. Le défi pour -l'utilisateur est de définir correctement l'ensemble des tableaux. Une fois l'ensemble -correctement défini, la fonction s'occupe de tout. - -Tout d'abord, la vignette présente le fonctionnement de la fonction, puis les -paramètres sont rapidement décrits. Dans la troisième partie, des exemples sont -développés pour montrer comment l'utiliser dans diverses situations. - -## Comment `tab_multi_manager()` gère-t-il la protection d'un ensemble de tableaux liées ? - -Tout d'abord, la fonction fusionne tous les tableaux de l'ensemble. Dans la table -obtenue, des variables booléennes sont ajoutées pour indiquer si une cellule -appartient à un tableau ou non. Il y a donc autant de variables booléennes que de -tableaux dans l'ensemble.Le tableau fusionné est un moyen très efficace pour détecter -rapidement les cellules communes. Ainsi ,le rapport des suppressions est automatisé. - -Le processus de protection est séquentiel : un tableau à la fois. Pour gérer la protection -de toutes les tables et ne pas oublier une table ou des liens, l'algorithme implémenté -fonctionne avec deux listes : - - - `todolist` : liste des tables qui doivent être protégées ; -- `remainlist` : liste des tables originales qui n'ont pas encore été protégées du tout. - -Les deux listes sont initialisées comme suit : - -- `todolist` = première table de la liste originale ; -- `remainlist` = toutes les tables originales sauf la première. - -Ensuite, l'algorithme se déroule comme indiqué dans la figure suivante : - -How tab_multi_manager's algorithm works - - -## Résultats - -La fonction renvoie la liste originale des tableaux avec d'autres variables qui -sont des variables booléennes (TRUE si la cellule doit être masquée sinon FALSE). -, décrivant toutes les étapes du processus de suppression. Chaque étape prend en -compte les résultats précédents et la dernière variable indique le statut final -d'une cellule. -Le statut final de chaque cellule est facilement déductible à l'aide de cette -dernière variable et de l'état de suppression primaire calculé précédemment par -l'utilisateur. - -De plus, la fonction écrit tous les fichiers τ-Argus créés au cours du processus. -A la fin, seul le dernier processus pour chaque table est disponible dans le -répertoire choisi. Un journal (`journal.txt`) est également fourni. Il décrit chaque -étape du processus de suppression : Quelle table est protégée, combien de nouvelles -cellules communes ont été atteintes par la suppression secondaire. -À la fin du processus, il décrit toutes les cellules communes qui ont été touchées, -en mentionnant l'itération à laquelle chacune a été masquée. - - -## Quelques détails sur les paramètres de `tab_multi_manager()`` - -- **dir_name** -le répertoire qui contiendra tous les fichiers créés, s'il n'existe pas, il sera créé. -exemple : dir_name = "my_directory". - -- **hrc** -Un vecteur nommé spécifiant le chemin vers le fichier hrc pour chaque variable hiérarchique. -exemple : c(ACTIVITY = "chemin_vers_fichier/act.hrc", NUTS = "chemin_vers_fichier/nuts.hrc" ) - -- **alt_hrc** -Une liste nommée utile pour traiter les hiérarchies non emboitées. Les noms de la liste -sont les noms des tableaux pour lesquelles une autre hiérarchie(non emboitée en général) -doit être utilisée. -exemple : Si T1 et T2 ont une variable explicative, appelée ACTIVITY, et la -même variable de réponse, mais la variable `ACTIVITY` n'a pas la même hiérarchie -dans les les deux tables. Supposons que les hiérarchies (act1.hrc et act2.hrc) ne -sont pas emboitées. Dans ce cas, nous écrivons les deux arguments comme suit : - - - hrc = c(ACTIVITY = "path_to_file/act_1.hrc") : Par défaut, cette hiérarchie sera - utilisée pour la variable ACTIVITY. - - alt_hrc = list(T2 = c(ACTIVITY = "chemin_vers_fichier/act_2.hrc")) : Dans la table T2, - la hiérarchie alternative sera utilisée. - -- **totcode** -Le code du total pour chaque variable explicative. Il est recommandé d'utiliser le même -même code de total pour chaque variable. Si par exemple le code est "Total" pour -toutes les variables. -La syntaxe qsuivante est autorisée : totcode = "Total" - -Sinon, l'input attendue est une liste spécifiant le code total pour chaque variable -explicative. -Par exemple : totcode = list(ACTIVITY = "Total", NUTS = "FR", SIZE = "Ensemble", CJ = "Total") - -Attention : Si les totaux ne sont pas dans la table, ils seront calculés par Tau-Argus, -mais ils ne seront pas éligibles pour la suppression primaire. Il est donc nécessaire -de les fournir dans la table de départ. - -- **alt_totcode** -Une liste nommée pour les codes de totaux alternatifs. Voir `alt_hrc` pour l'utilisation. - -- **value** -Le nom de colonne de la variable de réponse dans les tableauxs, il DOIT identique -pour chaque table. -Par exemple : valeur = "turnover". -Valeur par défaut : "value". - -- **freq** -Le nom de colonne de la variable de fréquence dans les tableaux, il DOIT être le -même nom pour chaque tableau. -Par exemple : freq = "frequency" -Valeur par défaut : "freq". - -- **secret_var** -Le nom de la variable booléenne spécifiant le secret primaire dans les tables, -il DOIT être le même nom pour chaque table. -Par exemple : secret_var = "is_secret_prim". -Valeur par défaut : "is_secret_prim". - -- **suppression** -L'algorithme requis pour effectuer la suppression secondaire, -expliqué dans la vignette safety_rules. Si Modular est choisi, après la -après la première itération sur une table donnée, les options singleton, -multi-singleton et minFreq sont désactivées. -défaut : MOD(1,5,1,0,0)" - -- **ip_start** - Les intervalles de protection pour la première itération sur une table donnée -(nombre entier) -par défaut : 10 - -- **ip_end** - Les intervalles de protection pour la deuxième itération sur une table -(nombre entier) -par défaut : 0 - -- **num_iter_max** -Nombre d'itération maximum sur un tableau, ce paramètre est ici pour assurer le -fait que la fonction va s'arrêter. En pratique on n'atteint jamais la limite de 10. -par défaut : 10 - -# Quelques exemples - -Spécifions l'emplacement du fichier TauArgus.exe sur notre ordinateur : - -``{r version} -options( - rtauargus.tauargus_exe = - "Y:/Logiciels/TauArgus/TauArgus4.2.3/TauArgus.exe" -) -``` - -## Comment protéger 4 tableaux liés en même temps - -Dans l'exemple suivant, nous allons protéger un ensemble de 4 tableaux liés partageant -la même variable de réponse, à savoir le chiffre d'affaires. - -### Préparation des données - - -``` r -data("turnover_act_size") -data("turnover_act_cj") -data ("turnover_nuts_size") -data("turnover_nuts_cj") -``` - -ACTIVITY X SIZE nommé turnover_act_size -ACTIVITY X CJ nommé turnover_act_cj -NUTS X SIZE nommé turnover_nuts_size -NUTS X CJ nommé turnover_nuts_cj - - - -``` r -str(turnover_act_size) -#> tibble [414 x 5] (S3: tbl_df/tbl/data.frame) -#> $ ACTIVITY: chr [1:414] "AZ" "BE" "FZ" "GI" ... -#> $ SIZE : chr [1:414] "Total" "Total" "Total" "Total" ... -#> $ N_OBS : int [1:414] 405 12878 28043 62053 8135 8140 11961 41359 26686 25108 ... -#> $ TOT : num [1:414] 44475 24827613 8907311 26962063 8584917 ... -#> $ MAX : num [1:414] 6212 1442029 1065833 3084242 3957364 ... -``` - -``` r -str(turnover_nuts_cj) -#> tibble [452 x 5] (S3: tbl_df/tbl/data.frame) -#> $ NUTS : chr [1:452] "FR10" "FR21" "FR22" "FR23" ... -#> $ CJ : chr [1:452] "Total" "Total" "Total" "Total" ... -#> $ N_OBS: int [1:452] 38462 6769 4561 5090 8611 7811 5643 10411 8179 5163 ... -#> $ TOT : num [1:452] 33026385 2947560 1917663 3701935 5089279 ... -#> $ MAX : num [1:452] 3084242 544763 651848 298134 1165019 ... -``` - -La première étape consiste à créer une liste contenant nos quatre tableaux, il est -conseillé de de donner un nom à chaque table. En faisant cela, il sera plus facile -de suivre le déroulement de la pose du secret secondaire. - - -``` r -list_data_4_tabs <- list( - act_size = turnover_act_size, - act_cj = turnover_act_cj, - nuts_size = turnover_nuts_size, - nuts_cj = turnover_nuts_cj -) -str(list_data_4_tabs) -#> List of 4 -#> $ act_size : tibble [414 x 5] (S3: tbl_df/tbl/data.frame) -#> ..$ ACTIVITY: chr [1:414] "AZ" "BE" "FZ" "GI" ... -#> ..$ SIZE : chr [1:414] "Total" "Total" "Total" "Total" ... -#> ..$ N_OBS : int [1:414] 405 12878 28043 62053 8135 8140 11961 41359 26686 25108 ... -#> ..$ TOT : num [1:414] 44475 24827613 8907311 26962063 8584917 ... -#> ..$ MAX : num [1:414] 6212 1442029 1065833 3084242 3957364 ... -#> $ act_cj : tibble [406 x 5] (S3: tbl_df/tbl/data.frame) -#> ..$ ACTIVITY: chr [1:406] "AZ" "BE" "FZ" "GI" ... -#> ..$ CJ : chr [1:406] "Total" "Total" "Total" "Total" ... -#> ..$ N_OBS : int [1:406] 405 12878 28043 62053 8135 8140 11961 41359 26686 25108 ... -#> ..$ TOT : num [1:406] 44475 24827613 8907311 26962063 8584917 ... -#> ..$ MAX : num [1:406] 6212 1442029 1065833 3084242 3957364 ... -#> $ nuts_size: tibble [460 x 5] (S3: tbl_df/tbl/data.frame) -#> ..$ NUTS : chr [1:460] "FR10" "FR21" "FR22" "FR23" ... -#> ..$ SIZE : chr [1:460] "Total" "Total" "Total" "Total" ... -#> ..$ N_OBS: int [1:460] 38462 6769 4561 5090 8611 7811 5643 10411 8179 5163 ... -#> ..$ TOT : num [1:460] 33026385 2947560 1917663 3701935 5089279 ... -#> ..$ MAX : num [1:460] 3084242 544763 651848 298134 1165019 ... -#> $ nuts_cj : tibble [452 x 5] (S3: tbl_df/tbl/data.frame) -#> ..$ NUTS : chr [1:452] "FR10" "FR21" "FR22" "FR23" ... -#> ..$ CJ : chr [1:452] "Total" "Total" "Total" "Total" ... -#> ..$ N_OBS: int [1:452] 38462 6769 4561 5090 8611 7811 5643 10411 8179 5163 ... -#> ..$ TOT : num [1:452] 33026385 2947560 1917663 3701935 5089279 ... -#> ..$ MAX : num [1:452] 3084242 544763 651848 298134 1165019 ... -``` - -### Appliquer les règles de secret primaire - -Ensuite, nous devons appliquer les règles de secret primaire pour chaque table. -Ici, nous appliquons 2 règles : -La règle de dominance à 85% NK(1,85) et la règle de fréquence avec un seuil fixé à 3. - - -``` r -list_data_4_tabs <- list_data_4_tabs %>% - purrr::map( - function(df){ - df %>% - mutate( - is_secret_freq = N_OBS > 0 & N_OBS < 3, - is_secret_dom = ifelse(MAX == 0, FALSE, MAX/TOT>0.85), - is_secret_prim = is_secret_freq | is_secret_dom - ) - } - ) -str(list_data_4_tabs) -#> List of 4 -#> $ act_size : tibble [414 x 8] (S3: tbl_df/tbl/data.frame) -#> ..$ ACTIVITY : chr [1:414] "AZ" "BE" "FZ" "GI" ... -#> ..$ SIZE : chr [1:414] "Total" "Total" "Total" "Total" ... -#> ..$ N_OBS : int [1:414] 405 12878 28043 62053 8135 8140 11961 41359 26686 25108 ... -#> ..$ TOT : num [1:414] 44475 24827613 8907311 26962063 8584917 ... -#> ..$ MAX : num [1:414] 6212 1442029 1065833 3084242 3957364 ... -#> ..$ is_secret_freq: logi [1:414] FALSE FALSE FALSE FALSE FALSE FALSE ... -#> ..$ is_secret_dom : logi [1:414] FALSE FALSE FALSE FALSE FALSE FALSE ... -#> ..$ is_secret_prim: logi [1:414] FALSE FALSE FALSE FALSE FALSE FALSE ... -#> $ act_cj : tibble [406 x 8] (S3: tbl_df/tbl/data.frame) -#> ..$ ACTIVITY : chr [1:406] "AZ" "BE" "FZ" "GI" ... -#> ..$ CJ : chr [1:406] "Total" "Total" "Total" "Total" ... -#> ..$ N_OBS : int [1:406] 405 12878 28043 62053 8135 8140 11961 41359 26686 25108 ... -#> ..$ TOT : num [1:406] 44475 24827613 8907311 26962063 8584917 ... -#> ..$ MAX : num [1:406] 6212 1442029 1065833 3084242 3957364 ... -#> ..$ is_secret_freq: logi [1:406] FALSE FALSE FALSE FALSE FALSE FALSE ... -#> ..$ is_secret_dom : logi [1:406] FALSE FALSE FALSE FALSE FALSE FALSE ... -#> ..$ is_secret_prim: logi [1:406] FALSE FALSE FALSE FALSE FALSE FALSE ... -#> $ nuts_size: tibble [460 x 8] (S3: tbl_df/tbl/data.frame) -#> ..$ NUTS : chr [1:460] "FR10" "FR21" "FR22" "FR23" ... -#> ..$ SIZE : chr [1:460] "Total" "Total" "Total" "Total" ... -#> ..$ N_OBS : int [1:460] 38462 6769 4561 5090 8611 7811 5643 10411 8179 5163 ... -#> ..$ TOT : num [1:460] 33026385 2947560 1917663 3701935 5089279 ... -#> ..$ MAX : num [1:460] 3084242 544763 651848 298134 1165019 ... -#> ..$ is_secret_freq: logi [1:460] FALSE FALSE FALSE FALSE FALSE FALSE ... -#> ..$ is_secret_dom : logi [1:460] FALSE FALSE FALSE FALSE FALSE FALSE ... -#> ..$ is_secret_prim: logi [1:460] FALSE FALSE FALSE FALSE FALSE FALSE ... -#> $ nuts_cj : tibble [452 x 8] (S3: tbl_df/tbl/data.frame) -#> ..$ NUTS : chr [1:452] "FR10" "FR21" "FR22" "FR23" ... -#> ..$ CJ : chr [1:452] "Total" "Total" "Total" "Total" ... -#> ..$ N_OBS : int [1:452] 38462 6769 4561 5090 8611 7811 5643 10411 8179 5163 ... -#> ..$ TOT : num [1:452] 33026385 2947560 1917663 3701935 5089279 ... -#> ..$ MAX : num [1:452] 3084242 544763 651848 298134 1165019 ... -#> ..$ is_secret_freq: logi [1:452] FALSE FALSE FALSE FALSE FALSE FALSE ... -#> ..$ is_secret_dom : logi [1:452] FALSE FALSE FALSE FALSE FALSE FALSE ... -#> ..$ is_secret_prim: logi [1:452] FALSE FALSE FALSE FALSE FALSE FALSE ... -``` - -Trois variables ont été ajoutées à chaque tableau. Seule la dernière sera utilisée -pendant le processus de suppression. Les deux autres seront utiles pour indiquer -l'état final des cellules. - -### Préparation de la liste des variables explicatives - -Nous allons ensuite créer la liste des variables explicatives des tableaux. -Dans notre cas, les variables explicatives sont les 2 premières colonnes de chaque tableau. - - -``` r -nom_var_list <- purrr::map( - list_data_4_tabs, - function(data) colnames(data)[1:2] -) -nom_var_list -#> $act_size -#> [1] "ACTIVITY" "SIZE" -#> -#> $act_cj -#> [1] "ACTIVITY" "CJ" -#> -#> $nuts_size -#> [1] "NUTS" "SIZE" -#> -#> $nuts_cj -#> [1] "NUTS" "CJ" -``` - -Les noms de la liste doivent être identiques aux noms des tableaux présent dans le paramètre -`list_tables`. - -### Préparation de la liste des codes pour les totaux - -Les modalités utilisées pour mentionner le total de chaque variable doivent être -déclarées par l'utilisateur, dans une liste nominative. Toutefois, lorsque toutes -les variables ont la même modalité pour pour le total, l'information peut être -spécifiée de la manière suivante : - - -``` r -total_codes <- "Total" -``` - -### Préparation des fichiers hiérarchiques - -`ACTIVITY` et `NUTS` sont duex variables hiérarchiques.On utilise une table de -correspondance pour chacunes d'entre elles pour créer le fichier .hrc dont τ-Argus -a besoin. - - -``` r -data(activity_corr_table) -data(nuts23_fr_corr_table) -``` - - -``` r -hrc_file_activity <- write_hrc2( - corr_table = activity_corr_table, - file_name = "hrc/activity.hrc" -) -hrc_file_nuts <- write_hrc2( - corr_table = nuts23_fr_corr_table, - file_name = "hrc/nuts.hrc" -) -``` - -Pour spécifier les nom des fichiers hrc, on crée un vecteur nommé (ou une liste) : - - -``` r -hrc_files <- list( - ACTIVITY = hrc_file_activity, - NUTS = hrc_file_nuts -) -``` - -Les noms du vecteur doivent être identiques aux noms des variables hiérarchiques -présentes dans la table - -### Protéger tous les tableaux en un seul appel - - -``` r -res <- tab_multi_manager( - list_tables = list_data_4_tabs, - list_explanatory_vars = nom_var_list, - dir_name = "tauargus_files/ex4", - hrc = hrc_files, - totcode = total_codes, - value = "TOT", - freq = "N_OBS", - secret_var = "is_secret_prim" -) -#> --- Current table to treat: act_size --- -#> --- Current table to treat: act_cj --- -#> --- Current table to treat: act_size --- -#> --- Current table to treat: nuts_size --- -#> --- Current table to treat: nuts_cj --- -``` - - -### Résultats - - -``` r -list_with_status <- res %>% - purrr::map( - function(df){ - df %>% - rename_with(~"final_suppress", last_col()) %>% - mutate( - status = case_when( - is_secret_freq ~ "A", - is_secret_dom ~ "B", - final_suppress ~ "D", - TRUE ~"V" - ) - ) %>% - select(1:2, TOT, N_OBS, status) - } - ) -str(list_with_status$act_size) -#> 'data.frame': 414 obs. of 5 variables: -#> $ ACTIVITY: chr "01" "01" "02" "02" ... -#> $ SIZE : chr "Total" "tr1" "Total" "tr1" ... -#> $ TOT : num 853 853 43623 35503 8120 ... -#> $ N_OBS : int 18 18 387 381 6 1 1 4 4 84 ... -#> $ status : chr "V" "V" "V" "V" ... -``` - - -``` r -list_with_status %>% - purrr::iwalk( - function(df,name){ - cat(name, "\n") - df %>% count(status) %>% print() - } - ) -#> act_size -#> status n -#> 1 A 52 -#> 2 B 25 -#> 3 D 83 -#> 4 V 254 -#> act_cj -#> status n -#> 1 A 35 -#> 2 B 25 -#> 3 D 88 -#> 4 V 258 -#> nuts_size -#> status n -#> 1 A 55 -#> 2 B 17 -#> 3 D 82 -#> 4 V 306 -#> nuts_cj -#> status n -#> 1 A 45 -#> 2 B 20 -#> 3 D 101 -#> 4 V 286 -``` - -## Traiter les hiérarchies non emboitées - -Supposons que l'on veuille protéger les deux tableaux croisant `ACTIVITY` et -`SIZE` d'une part et `ACTIVITY` et `CJ` d'autre part. La variable `ACTIVITY` est une variable hiérarchique. De plus, dans ce cas, nous aimerions publier un sous-total, appelé `D_TO_M`, en plus de ceux de la `activity_corr_table`. Ce sous-total est la somme des étiquettes `D` à `M` du niveau `A21`. Comme ce sous-total ne peut pas être inséré dans la hiérarchie principale, cela nous conduit à un cas de hiérarchies non emboitées. - -Pour confirmer le non-emboîtement des deux hiérarchies, affichons un extrait des deux. - -Extrait de la hiérarchie principale : - - -``` r -sdcHierarchies::hier_create( - root="Total", - nodes = activity_corr_table$A10 %>% unique() -) %>% - sdcHierarchies::hier_display() -#> Total -#> +-AZ -#> +-BE -#> +-FZ -#> +-GI -#> +-JZ -#> +-KZ -#> +-LZ -#> +-MN -#> +-OQ -#> \-RU -``` - -Extrait de la hiérarchie alternative: - - -``` r -sdcHierarchies::hier_create( - root="D_TO_M", - nodes = activity_corr_table_D_TO_M$A21 -) %>% - sdcHierarchies::hier_display() -#> D_TO_M -#> +-D -#> +-E -#> +-F -#> +-G -#> +-H -#> +-I -#> +-J -#> +-K -#> +-L -#> \-M -``` - -Pour traiter ce cas, l'approche préférée est de créer un troisième tableau croisant -`ACTIVITY` et `SIZE` avec les modalités D à M et le sous-total `D_TO_M` : - - -``` r -turnover_act_size_D_TO_M <- turnover_act_size %>% - filter( - ACTIVITY %in% LETTERS[4:13] - ) %>% - bind_rows( - turnover_act_size %>% - filter( - ACTIVITY %in% LETTERS[4:13] - ) %>% - group_by(SIZE) %>% - summarise(N_OBS = sum(N_OBS), TOT = sum(TOT), MAX = max(MAX)) %>% - mutate(ACTIVITY = "D_TO_M") - ) -str(turnover_act_size_D_TO_M) -#> tibble [44 x 5] (S3: tbl_df/tbl/data.frame) -#> $ ACTIVITY: chr [1:44] "D" "E" "F" "G" ... -#> $ SIZE : chr [1:44] "Total" "Total" "Total" "Total" ... -#> $ N_OBS : int [1:44] 1411 828 28043 41624 6524 13905 8135 8140 11961 28221 ... -#> $ TOT : num [1:44] 2438454 2264393 8907311 18244309 6273334 ... -#> $ MAX : num [1:44] 981369 306905 1065833 765244 3084242 ... -``` - -Créons le fichier correspondant à cette hiérarchie : - - -``` r -activity_corr_table_D_TO_M <- activity_corr_table %>% - filter(A21 %in% LETTERS[4:13]) %>% - select(-A88) %>% - mutate(A10 = "D_TO_M") %>% - unique() - -hrc_file_activity_D_TO_M <- activity_corr_table_D_TO_M %>% - select(-1) %>% - write_hrc2(file_name = "hrc/activity_D_TO_M") -``` - -Ensuite, construisons la liste des tableaux et appliquons les règles de secret -primaire dessus. - - -``` r -list_data_3_tabs_nn <- list( - act_size = turnover_act_size, - act_size_D_TO_M = turnover_act_size_D_TO_M, - act_cj = turnover_act_cj -) %>% - purrr::map( - function(df){ - df %>% - mutate( - is_secret_freq = N_OBS > 0 & N_OBS < 3, - is_secret_dom = ifelse(MAX == 0, FALSE, MAX/TOT>0.85), - is_secret_prim = is_secret_freq | is_secret_dom - ) - } - ) -``` - -Les arguments `hrc` et `alt_hrc` sont utilisés pour mentionner les deux hiérarchies -de la variable `ACTIVITY` : - - - `hrc` est utilisé comme dans l'exemple précédent (un vecteur nommé où les noms -sont les différentes variables hiérarchiques apparaissant dans les tableaux et les -valeurs sont les noms des fichiers). Ainsi, le fichier de hiérarchie par défaut -sera pris dans ce vecteur. -- `alt_hrc` n'est utilisé que pour mentionner les hiérarchies alternatives. -Cet argument est une liste nommée où les noms sont les tableaux où les hiérarchies -alternatives doivent être appliquées. - -Le même raisonnement est utilisé pour remplir l'argument `alt_totcode`. - - -``` r -res <- tab_multi_manager( - list_tables = list_data_3_tabs_nn, - list_explanatory_vars = list( - act_size = c("ACTIVITY", "SIZE"), - act_size_D_TO_M = c("ACTIVITY", "SIZE"), - act_cj = c("ACTIVITY", "CJ") - ), - hrc = c(ACTIVITY = hrc_file_activity), - alt_hrc = list( - act_size_D_TO_M = c(ACTIVITY = hrc_file_activity_D_TO_M) - ), - dir_name = "tauargus_files/ex5", - value = "TOT", - freq = "N_OBS", - secret_var = "is_secret_prim", - totcode = "Total", - alt_totcode = list( - act_size_D_TO_M = c(ACTIVITY = "D_TO_M") - ) -) -#> --- Current table to treat: act_size --- -#> --- Current table to treat: act_size_D_TO_M --- -#> --- Current table to treat: act_cj --- -#> --- Current table to treat: act_size --- -#> --- Current table to treat: act_size_D_TO_M --- -#> --- Current table to treat: act_size --- -#> --- Current table to treat: act_cj --- -``` - -#### Détail de la vignette - -- Authors: **Julien Jamme** & **Nathanael Rastout** - - Last update: **17/02/2025** - - Version of rtauargus used: **1.2.999** - - Version of τ-Argus used : **TauArgus 4.2.3** - - R version used : **4.3.3** - -

- summary ↑ -

+--- +title: "Protéger des tableaux liés" +subtitle:

![logo R](R_logo_small.png)![logo τ-Argus](TauBall2_small.png)
Package {rtauargus}

+output: + rmarkdown::html_vignette: + toc: true + toc_depth: 2 + number_section: true + fig_caption: true +vignette: > + %\VignetteIndexEntry{Protéger des tableaux liés} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + + + + + +# Introduction + +Dans le package `rtauargus`, il est maintenant possible de protéger un ensemble +de tableaux liés en une seule fois. La fonction pour le faire s'appelle +`tab_multi_manager()`. L'algorithme très simple implémenté pour gérer la protection +ne dépend pas du nombre de tableaux. Par conséquent,la fonction peut théoriquement +traiter un nombre indéfini de tableaux. Bien sûr, l'utilisation pratique est limitée +par la puissance de l'ordinateur. Cependant, nous sommes confiants sur la capacité +de la fonction à traiter la plupart des cas. Nous sommes intéressés par les cas que +vous pourriez rencontrer et que la fonction ne peut pas traiter. + +Un lien entre deux (ou plusieurs) tableaux décrit les cellules communes des tableaux, +c'est-à-dire les cellules qui sont présentes dans ces derniers. +La fonction peut gérer tous les types de liens entre tableaux : + +- les marges communes : lorsque deux tableaux partagent une (ou plusieurs) +variables de ventilation ; +- liens entre les variables de réponse, lorsqu'il existe des équations reliant +les variables ; +- hiérarchies non emboitées : lorsqu'une variable explicative est décomposée en +deux (ou plus) hiérarchies non emboitées. + +En fait, les deux derniers types peuvent être traités comme le premier. Le défi pour +l'utilisateur est de définir correctement l'ensemble des tableaux. Une fois l'ensemble +correctement défini, la fonction s'occupe de tout. + +Tout d'abord, la vignette présente le fonctionnement de la fonction, puis les +paramètres sont rapidement décrits. Dans la troisième partie, des exemples sont +développés pour montrer comment l'utiliser dans diverses situations. + +## Comment `tab_multi_manager()` gère-t-il la protection d'un ensemble de tableaux liées ? + +Tout d'abord, la fonction fusionne tous les tableaux de l'ensemble. Dans la table +obtenue, des variables booléennes sont ajoutées pour indiquer si une cellule +appartient à un tableau ou non. Il y a donc autant de variables booléennes que de +tableaux dans l'ensemble.Le tableau fusionné est un moyen très efficace pour détecter +rapidement les cellules communes. Ainsi ,le rapport des suppressions est automatisé. + +Le processus de protection est séquentiel : un tableau à la fois. Pour gérer la protection +de toutes les tables et ne pas oublier une table ou des liens, l'algorithme implémenté +fonctionne avec deux listes : + + - `todolist` : liste des tables qui doivent être protégées ; +- `remainlist` : liste des tables originales qui n'ont pas encore été protégées du tout. + +Les deux listes sont initialisées comme suit : + +- `todolist` = première table de la liste originale ; +- `remainlist` = toutes les tables originales sauf la première. + +Ensuite, l'algorithme se déroule comme indiqué dans la figure suivante : + +How tab_multi_manager's algorithm works + + +## Résultats + +La fonction renvoie la liste originale des tableaux avec d'autres variables qui +sont des variables booléennes (TRUE si la cellule doit être masquée sinon FALSE). +, décrivant toutes les étapes du processus de suppression. Chaque étape prend en +compte les résultats précédents et la dernière variable indique le statut final +d'une cellule. +Le statut final de chaque cellule est facilement déductible à l'aide de cette +dernière variable et de l'état de suppression primaire calculé précédemment par +l'utilisateur. + +De plus, la fonction écrit tous les fichiers τ-Argus créés au cours du processus. +A la fin, seul le dernier processus pour chaque table est disponible dans le +répertoire choisi. Un journal (`journal.txt`) est également fourni. Il décrit chaque +étape du processus de suppression : Quelle table est protégée, combien de nouvelles +cellules communes ont été atteintes par la suppression secondaire. +À la fin du processus, il décrit toutes les cellules communes qui ont été touchées, +en mentionnant l'itération à laquelle chacune a été masquée. + + +## Quelques détails sur les paramètres de `tab_multi_manager()`` + +- **dir_name** +le répertoire qui contiendra tous les fichiers créés, s'il n'existe pas, il sera créé. +exemple : dir_name = "my_directory". + +- **hrc** +Un vecteur nommé spécifiant le chemin vers le fichier hrc pour chaque variable hiérarchique. +exemple : c(ACTIVITY = "chemin_vers_fichier/act.hrc", NUTS = "chemin_vers_fichier/nuts.hrc" ) + +- **alt_hrc** +Une liste nommée utile pour traiter les hiérarchies non emboitées. Les noms de la liste +sont les noms des tableaux pour lesquelles une autre hiérarchie(non emboitée en général) +doit être utilisée. +exemple : Si T1 et T2 ont une variable explicative, appelée ACTIVITY, et la +même variable de réponse, mais la variable `ACTIVITY` n'a pas la même hiérarchie +dans les les deux tables. Supposons que les hiérarchies (act1.hrc et act2.hrc) ne +sont pas emboitées. Dans ce cas, nous écrivons les deux arguments comme suit : + + - hrc = c(ACTIVITY = "path_to_file/act_1.hrc") : Par défaut, cette hiérarchie sera + utilisée pour la variable ACTIVITY. + - alt_hrc = list(T2 = c(ACTIVITY = "chemin_vers_fichier/act_2.hrc")) : Dans la table T2, + la hiérarchie alternative sera utilisée. + +- **totcode** +Le code du total pour chaque variable explicative. Il est recommandé d'utiliser le même +même code de total pour chaque variable. Si par exemple le code est "Total" pour +toutes les variables. +La syntaxe suivante est autorisée : totcode = "Total" + +Sinon, l'input attendue est une liste spécifiant le code total pour chaque variable +explicative. +Par exemple : totcode = list(ACTIVITY = "Total", NUTS = "FR", SIZE = "Ensemble", CJ = "Total") + +Attention : Si les totaux ne sont pas dans la table, ils seront calculés par Tau-Argus, +mais ils ne seront pas éligibles pour la suppression primaire. Il est donc nécessaire +de les fournir dans la table de départ. + +- **alt_totcode** +Une liste nommée pour les codes de totaux alternatifs. Voir `alt_hrc` pour l'utilisation. + +- **value** +Le nom de colonne de la variable de réponse dans les tableauxs, il DOIT identique +pour chaque table. +Par exemple : valeur = "turnover". +Valeur par défaut : "value". + +- **freq** +Le nom de colonne de la variable de fréquence dans les tableaux, il DOIT être le +même nom pour chaque tableau. +Par exemple : freq = "frequency" +Valeur par défaut : "freq". + +- **secret_var** +Le nom de la variable booléenne spécifiant le secret primaire dans les tables, +il DOIT être le même nom pour chaque table. +Par exemple : secret_var = "is_secret_prim". +Valeur par défaut : "is_secret_prim". + +- **suppression** +L'algorithme requis pour effectuer la suppression secondaire, +expliqué dans la vignette safety_rules. Si Modular est choisi, après la +après la première itération sur une table donnée, les options singleton, +multi-singleton et minFreq sont désactivées. +défaut : MOD(1,5,1,0,0)" + +- **ip_start** + Les intervalles de protection pour la première itération sur une table donnée +(nombre entier) +par défaut : 10 + +- **ip_end** + Les intervalles de protection pour la deuxième itération sur une table +(nombre entier) +par défaut : 0 + +- **num_iter_max** +Nombre d'itération maximum sur un tableau, ce paramètre est ici pour assurer le +fait que la fonction va s'arrêter. En pratique on n'atteint jamais la limite de 10. +par défaut : 10 + +# Quelques exemples + +Spécifions l'emplacement du fichier TauArgus.exe sur notre ordinateur : + +``{r version} +options( + rtauargus.tauargus_exe = + "Y:/Logiciels/TauArgus/TauArgus4.2.3/TauArgus.exe" +) +``` + +## Comment protéger 4 tableaux liés en même temps + +Dans l'exemple suivant, nous allons protéger un ensemble de 4 tableaux liés partageant +la même variable de réponse, à savoir le chiffre d'affaires. + +### Préparation des données + + +``` r +data("turnover_act_size") +data("turnover_act_cj") +data ("turnover_nuts_size") +data("turnover_nuts_cj") +``` + +ACTIVITY X SIZE nommé turnover_act_size +ACTIVITY X CJ nommé turnover_act_cj +NUTS X SIZE nommé turnover_nuts_size +NUTS X CJ nommé turnover_nuts_cj + + + +``` r +str(turnover_act_size) +#> tibble [414 x 5] (S3: tbl_df/tbl/data.frame) +#> $ ACTIVITY: chr [1:414] "AZ" "BE" "FZ" "GI" ... +#> $ SIZE : chr [1:414] "Total" "Total" "Total" "Total" ... +#> $ N_OBS : int [1:414] 405 12878 28043 62053 8135 8140 11961 41359 26686 25108 ... +#> $ TOT : num [1:414] 44475 24827613 8907311 26962063 8584917 ... +#> $ MAX : num [1:414] 6212 1442029 1065833 3084242 3957364 ... +str(turnover_nuts_cj) +#> tibble [452 x 5] (S3: tbl_df/tbl/data.frame) +#> $ NUTS : chr [1:452] "FR10" "FR21" "FR22" "FR23" ... +#> $ CJ : chr [1:452] "Total" "Total" "Total" "Total" ... +#> $ N_OBS: int [1:452] 38462 6769 4561 5090 8611 7811 5643 10411 8179 5163 ... +#> $ TOT : num [1:452] 33026385 2947560 1917663 3701935 5089279 ... +#> $ MAX : num [1:452] 3084242 544763 651848 298134 1165019 ... +``` + +La première étape consiste à créer une liste contenant nos quatre tableaux, il est +conseillé de donner un nom à chaque table. En faisant cela, il sera plus facile +de suivre le déroulement de la pose du secret secondaire. + + +``` r +list_data_4_tabs <- list( + act_size = turnover_act_size, + act_cj = turnover_act_cj, + nuts_size = turnover_nuts_size, + nuts_cj = turnover_nuts_cj +) +str(list_data_4_tabs) +#> List of 4 +#> $ act_size : tibble [414 x 5] (S3: tbl_df/tbl/data.frame) +#> ..$ ACTIVITY: chr [1:414] "AZ" "BE" "FZ" "GI" ... +#> ..$ SIZE : chr [1:414] "Total" "Total" "Total" "Total" ... +#> ..$ N_OBS : int [1:414] 405 12878 28043 62053 8135 8140 11961 41359 26686 25108 ... +#> ..$ TOT : num [1:414] 44475 24827613 8907311 26962063 8584917 ... +#> ..$ MAX : num [1:414] 6212 1442029 1065833 3084242 3957364 ... +#> $ act_cj : tibble [406 x 5] (S3: tbl_df/tbl/data.frame) +#> ..$ ACTIVITY: chr [1:406] "AZ" "BE" "FZ" "GI" ... +#> ..$ CJ : chr [1:406] "Total" "Total" "Total" "Total" ... +#> ..$ N_OBS : int [1:406] 405 12878 28043 62053 8135 8140 11961 41359 26686 25108 ... +#> ..$ TOT : num [1:406] 44475 24827613 8907311 26962063 8584917 ... +#> ..$ MAX : num [1:406] 6212 1442029 1065833 3084242 3957364 ... +#> $ nuts_size: tibble [460 x 5] (S3: tbl_df/tbl/data.frame) +#> ..$ NUTS : chr [1:460] "FR10" "FR21" "FR22" "FR23" ... +#> ..$ SIZE : chr [1:460] "Total" "Total" "Total" "Total" ... +#> ..$ N_OBS: int [1:460] 38462 6769 4561 5090 8611 7811 5643 10411 8179 5163 ... +#> ..$ TOT : num [1:460] 33026385 2947560 1917663 3701935 5089279 ... +#> ..$ MAX : num [1:460] 3084242 544763 651848 298134 1165019 ... +#> $ nuts_cj : tibble [452 x 5] (S3: tbl_df/tbl/data.frame) +#> ..$ NUTS : chr [1:452] "FR10" "FR21" "FR22" "FR23" ... +#> ..$ CJ : chr [1:452] "Total" "Total" "Total" "Total" ... +#> ..$ N_OBS: int [1:452] 38462 6769 4561 5090 8611 7811 5643 10411 8179 5163 ... +#> ..$ TOT : num [1:452] 33026385 2947560 1917663 3701935 5089279 ... +#> ..$ MAX : num [1:452] 3084242 544763 651848 298134 1165019 ... +``` + +### Appliquer les règles de secret primaire + +Ensuite, nous devons appliquer les règles de secret primaire pour chaque table. +Ici, nous appliquons 2 règles : +La règle de dominance à 85% NK(1,85) et la règle de fréquence avec un seuil fixé à 3. + + +``` r +list_data_4_tabs <- list_data_4_tabs %>% + purrr::map( + function(df){ + df %>% + mutate( + is_secret_freq = N_OBS > 0 & N_OBS < 3, + is_secret_dom = ifelse(MAX == 0, FALSE, MAX/TOT>0.85), + is_secret_prim = is_secret_freq | is_secret_dom + ) + } + ) +str(list_data_4_tabs) +#> List of 4 +#> $ act_size : tibble [414 x 8] (S3: tbl_df/tbl/data.frame) +#> ..$ ACTIVITY : chr [1:414] "AZ" "BE" "FZ" "GI" ... +#> ..$ SIZE : chr [1:414] "Total" "Total" "Total" "Total" ... +#> ..$ N_OBS : int [1:414] 405 12878 28043 62053 8135 8140 11961 41359 26686 25108 ... +#> ..$ TOT : num [1:414] 44475 24827613 8907311 26962063 8584917 ... +#> ..$ MAX : num [1:414] 6212 1442029 1065833 3084242 3957364 ... +#> ..$ is_secret_freq: logi [1:414] FALSE FALSE FALSE FALSE FALSE FALSE ... +#> ..$ is_secret_dom : logi [1:414] FALSE FALSE FALSE FALSE FALSE FALSE ... +#> ..$ is_secret_prim: logi [1:414] FALSE FALSE FALSE FALSE FALSE FALSE ... +#> $ act_cj : tibble [406 x 8] (S3: tbl_df/tbl/data.frame) +#> ..$ ACTIVITY : chr [1:406] "AZ" "BE" "FZ" "GI" ... +#> ..$ CJ : chr [1:406] "Total" "Total" "Total" "Total" ... +#> ..$ N_OBS : int [1:406] 405 12878 28043 62053 8135 8140 11961 41359 26686 25108 ... +#> ..$ TOT : num [1:406] 44475 24827613 8907311 26962063 8584917 ... +#> ..$ MAX : num [1:406] 6212 1442029 1065833 3084242 3957364 ... +#> ..$ is_secret_freq: logi [1:406] FALSE FALSE FALSE FALSE FALSE FALSE ... +#> ..$ is_secret_dom : logi [1:406] FALSE FALSE FALSE FALSE FALSE FALSE ... +#> ..$ is_secret_prim: logi [1:406] FALSE FALSE FALSE FALSE FALSE FALSE ... +#> $ nuts_size: tibble [460 x 8] (S3: tbl_df/tbl/data.frame) +#> ..$ NUTS : chr [1:460] "FR10" "FR21" "FR22" "FR23" ... +#> ..$ SIZE : chr [1:460] "Total" "Total" "Total" "Total" ... +#> ..$ N_OBS : int [1:460] 38462 6769 4561 5090 8611 7811 5643 10411 8179 5163 ... +#> ..$ TOT : num [1:460] 33026385 2947560 1917663 3701935 5089279 ... +#> ..$ MAX : num [1:460] 3084242 544763 651848 298134 1165019 ... +#> ..$ is_secret_freq: logi [1:460] FALSE FALSE FALSE FALSE FALSE FALSE ... +#> ..$ is_secret_dom : logi [1:460] FALSE FALSE FALSE FALSE FALSE FALSE ... +#> ..$ is_secret_prim: logi [1:460] FALSE FALSE FALSE FALSE FALSE FALSE ... +#> $ nuts_cj : tibble [452 x 8] (S3: tbl_df/tbl/data.frame) +#> ..$ NUTS : chr [1:452] "FR10" "FR21" "FR22" "FR23" ... +#> ..$ CJ : chr [1:452] "Total" "Total" "Total" "Total" ... +#> ..$ N_OBS : int [1:452] 38462 6769 4561 5090 8611 7811 5643 10411 8179 5163 ... +#> ..$ TOT : num [1:452] 33026385 2947560 1917663 3701935 5089279 ... +#> ..$ MAX : num [1:452] 3084242 544763 651848 298134 1165019 ... +#> ..$ is_secret_freq: logi [1:452] FALSE FALSE FALSE FALSE FALSE FALSE ... +#> ..$ is_secret_dom : logi [1:452] FALSE FALSE FALSE FALSE FALSE FALSE ... +#> ..$ is_secret_prim: logi [1:452] FALSE FALSE FALSE FALSE FALSE FALSE ... +``` + +Trois variables ont été ajoutées à chaque tableau. Seule la dernière sera utilisée +pendant le processus de suppression. Les deux autres seront utiles pour indiquer +l'état final des cellules. + +### Préparation de la liste des variables explicatives + +Nous allons ensuite créer la liste des variables explicatives des tableaux. +Dans notre cas, les variables explicatives sont les 2 premières colonnes de chaque tableau. + + +``` r +nom_var_list <- purrr::map( + list_data_4_tabs, + function(data) colnames(data)[1:2] +) +nom_var_list +#> $act_size +#> [1] "ACTIVITY" "SIZE" +#> +#> $act_cj +#> [1] "ACTIVITY" "CJ" +#> +#> $nuts_size +#> [1] "NUTS" "SIZE" +#> +#> $nuts_cj +#> [1] "NUTS" "CJ" +``` + +Les noms de la liste doivent être identiques aux noms des tableaux présent dans le paramètre +`list_tables`. + +### Préparation de la liste des codes pour les totaux + +Les modalités utilisées pour mentionner le total de chaque variable doivent être +déclarées par l'utilisateur, dans une liste nominative. Toutefois, lorsque toutes +les variables ont la même modalité pour le total, l'information peut être +spécifiée de la manière suivante : + + +``` r +total_codes <- "Total" +``` + +### Préparation des fichiers hiérarchiques + +`ACTIVITY` et `NUTS` sont deux variables hiérarchiques. On utilise une table de +correspondance pour chacune d'entre elles pour créer le fichier .hrc dont τ-Argus +a besoin. + + +``` r +data(activity_corr_table) +data(nuts23_fr_corr_table) +``` + + +``` r +hrc_file_activity <- write_hrc2( + corr_table = activity_corr_table, + file_name = "hrc/activity.hrc" +) +hrc_file_nuts <- write_hrc2( + corr_table = nuts23_fr_corr_table, + file_name = "hrc/nuts.hrc" +) +``` + +Pour spécifier les nom des fichiers hrc, on crée un vecteur nommé (ou une liste) : + + +``` r +hrc_files <- list( + ACTIVITY = hrc_file_activity, + NUTS = hrc_file_nuts +) +``` + +Les noms du vecteur doivent être identiques aux noms des variables hiérarchiques +présentes dans la table + +### Protéger tous les tableaux en un seul appel + + +``` r +res <- tab_multi_manager( + list_tables = list_data_4_tabs, + list_explanatory_vars = nom_var_list, + dir_name = "tauargus_files/ex4", + hrc = hrc_files, + totcode = total_codes, + value = "TOT", + freq = "N_OBS", + secret_var = "is_secret_prim" +) +#> --- Current table to treat: act_size | loop iter : 1 --- --- Current table to treat: act_cj | loop iter : 2 --- --- Current table to treat: act_size | loop iter : 3 --- --- Current table to treat: nuts_size | loop iter : 4 --- --- Current table to treat: nuts_cj | loop iter : 5 --- +``` + + +### Résultats + + +``` r +list_with_status <- res %>% + purrr::map( + function(df){ + df %>% + rename_with(~"final_suppress", last_col()) %>% + mutate( + status = case_when( + is_secret_freq ~ "A", + is_secret_dom ~ "B", + final_suppress ~ "D", + TRUE ~"V" + ) + ) %>% + select(1:2, TOT, N_OBS, status) + } + ) +str(list_with_status$act_size) +#> 'data.frame': 414 obs. of 5 variables: +#> $ ACTIVITY: chr "01" "01" "02" "02" ... +#> $ SIZE : chr "Total" "tr1" "Total" "tr1" ... +#> $ TOT : num 853 853 43623 35503 8120 ... +#> $ N_OBS : int 18 18 387 381 6 1 1 4 4 84 ... +#> $ status : chr "V" "V" "V" "V" ... +``` + + +``` r +list_with_status %>% + purrr::iwalk( + function(df,name){ + cat(name, "\n") + df %>% count(status) %>% print() + } + ) +#> act_size +#> status n +#> 1 A 52 +#> 2 B 25 +#> 3 D 83 +#> 4 V 254 +#> act_cj +#> status n +#> 1 A 35 +#> 2 B 25 +#> 3 D 88 +#> 4 V 258 +#> nuts_size +#> status n +#> 1 A 55 +#> 2 B 17 +#> 3 D 82 +#> 4 V 306 +#> nuts_cj +#> status n +#> 1 A 45 +#> 2 B 20 +#> 3 D 101 +#> 4 V 286 +``` + +## Traiter les hiérarchies non emboitées + +Supposons que l'on veuille protéger les deux tableaux croisant `ACTIVITY` et +`SIZE` d'une part et `ACTIVITY` et `CJ` d'autre part. La variable `ACTIVITY` est une variable hiérarchique. De plus, dans ce cas, nous aimerions publier un sous-total, appelé `D_TO_M`, en plus de ceux de la `activity_corr_table`. Ce sous-total est la somme des étiquettes `D` à `M` du niveau `A21`. Comme ce sous-total ne peut pas être inséré dans la hiérarchie principale, cela nous conduit à un cas de hiérarchies non emboitées. + +Pour confirmer le non-emboîtement des deux hiérarchies, affichons un extrait des deux. + +Extrait de la hiérarchie principale : + + +``` r +sdcHierarchies::hier_create( + root="Total", + nodes = activity_corr_table$A10 %>% unique() +) %>% + sdcHierarchies::hier_display() +#> Total +#> +-AZ +#> +-BE +#> +-FZ +#> +-GI +#> +-JZ +#> +-KZ +#> +-LZ +#> +-MN +#> +-OQ +#> \-RU +``` + +Extrait de la hiérarchie alternative: + + +``` r +sdcHierarchies::hier_create( + root="D_TO_M", + nodes = activity_corr_table_D_TO_M$A21 +) %>% + sdcHierarchies::hier_display() +#> D_TO_M +#> +-D +#> +-E +#> +-F +#> +-G +#> +-H +#> +-I +#> +-J +#> +-K +#> +-L +#> \-M +``` + +Pour traiter ce cas, l'approche préférée est de créer un troisième tableau croisant +`ACTIVITY` et `SIZE` avec les modalités D à M et le sous-total `D_TO_M` : + + +``` r +turnover_act_size_D_TO_M <- turnover_act_size %>% + filter( + ACTIVITY %in% LETTERS[4:13] + ) %>% + bind_rows( + turnover_act_size %>% + filter( + ACTIVITY %in% LETTERS[4:13] + ) %>% + group_by(SIZE) %>% + summarise(N_OBS = sum(N_OBS), TOT = sum(TOT), MAX = max(MAX)) %>% + mutate(ACTIVITY = "D_TO_M") + ) +str(turnover_act_size_D_TO_M) +#> tibble [44 x 5] (S3: tbl_df/tbl/data.frame) +#> $ ACTIVITY: chr [1:44] "D" "E" "F" "G" ... +#> $ SIZE : chr [1:44] "Total" "Total" "Total" "Total" ... +#> $ N_OBS : int [1:44] 1411 828 28043 41624 6524 13905 8135 8140 11961 28221 ... +#> $ TOT : num [1:44] 2438454 2264393 8907311 18244309 6273334 ... +#> $ MAX : num [1:44] 981369 306905 1065833 765244 3084242 ... +``` + +Créons le fichier correspondant à cette hiérarchie : + + +``` r +activity_corr_table_D_TO_M <- activity_corr_table %>% + filter(A21 %in% LETTERS[4:13]) %>% + select(-A88) %>% + mutate(A10 = "D_TO_M") %>% + unique() + +hrc_file_activity_D_TO_M <- activity_corr_table_D_TO_M %>% + select(-1) %>% + write_hrc2(file_name = "hrc/activity_D_TO_M") +``` + +Ensuite, construisons la liste des tableaux et appliquons les règles de secret +primaire dessus. + + +``` r +list_data_3_tabs_nn <- list( + act_size = turnover_act_size, + act_size_D_TO_M = turnover_act_size_D_TO_M, + act_cj = turnover_act_cj +) %>% + purrr::map( + function(df){ + df %>% + mutate( + is_secret_freq = N_OBS > 0 & N_OBS < 3, + is_secret_dom = ifelse(MAX == 0, FALSE, MAX/TOT>0.85), + is_secret_prim = is_secret_freq | is_secret_dom + ) + } + ) +``` + +Les arguments `hrc` et `alt_hrc` sont utilisés pour mentionner les deux hiérarchies +de la variable `ACTIVITY` : + + - `hrc` est utilisé comme dans l'exemple précédent (un vecteur nommé où les noms +sont les différentes variables hiérarchiques apparaissant dans les tableaux et les +valeurs sont les noms des fichiers). Ainsi, le fichier de hiérarchie par défaut +sera pris dans ce vecteur. +- `alt_hrc` n'est utilisé que pour mentionner les hiérarchies alternatives. +Cet argument est une liste nommée où les noms sont les tableaux où les hiérarchies +alternatives doivent être appliquées. + +Le même raisonnement est utilisé pour remplir l'argument `alt_totcode`. + + +``` r +res <- tab_multi_manager( + list_tables = list_data_3_tabs_nn, + list_explanatory_vars = list( + act_size = c("ACTIVITY", "SIZE"), + act_size_D_TO_M = c("ACTIVITY", "SIZE"), + act_cj = c("ACTIVITY", "CJ") + ), + hrc = c(ACTIVITY = hrc_file_activity), + alt_hrc = list( + act_size_D_TO_M = c(ACTIVITY = hrc_file_activity_D_TO_M) + ), + dir_name = "tauargus_files/ex5", + value = "TOT", + freq = "N_OBS", + secret_var = "is_secret_prim", + totcode = "Total", + alt_totcode = list( + act_size_D_TO_M = c(ACTIVITY = "D_TO_M") + ) +) +#> --- Current table to treat: act_size | loop iter : 1 --- --- Current table to treat: act_size_D_TO_M | loop iter : 2 --- --- Current table to treat: act_cj | loop iter : 3 --- --- Current table to treat: act_size | loop iter : 4 --- --- Current table to treat: act_size_D_TO_M | loop iter : 5 --- --- Current table to treat: act_size | loop iter : 6 --- --- Current table to treat: act_cj | loop iter : 7 --- +``` + +#### Détail de la vignette + +- Authors: **Julien Jamme** & **Nathanael Rastout** + - Last update: **27/10/2026** + - Version of rtauargus used: **1.3.6** + - Version of τ-Argus used : **TauArgus 4.2.3** + - R version used : **4.5.3** + +

+ summary ↑ +

diff --git a/vignettes/protect_multi_tables_fr.Rmd.orig b/vignettes/protect_multi_tables_fr.Rmd.orig index 4be1366..0edea3f 100644 --- a/vignettes/protect_multi_tables_fr.Rmd.orig +++ b/vignettes/protect_multi_tables_fr.Rmd.orig @@ -41,7 +41,7 @@ de la fonction à traiter la plupart des cas. Nous sommes intéressés par les c vous pourriez rencontrer et que la fonction ne peut pas traiter. Un lien entre deux (ou plusieurs) tableaux décrit les cellules communes des tableaux, -c'est-à-dire les cellules qui sont présentent dans ces derniers. +c'est-à-dire les cellules qui sont présentes dans ces derniers. La fonction peut gérer tous les types de liens entre tableaux : - les marges communes : lorsque deux tableaux partagent une (ou plusieurs) @@ -132,7 +132,7 @@ sont pas emboitées. Dans ce cas, nous écrivons les deux arguments comme suit : Le code du total pour chaque variable explicative. Il est recommandé d'utiliser le même même code de total pour chaque variable. Si par exemple le code est "Total" pour toutes les variables. -La syntaxe qsuivante est autorisée : totcode = "Total" +La syntaxe suivante est autorisée : totcode = "Total" Sinon, l'input attendue est une liste spécifiant le code total pour chaque variable explicative. @@ -222,7 +222,7 @@ str(turnover_nuts_cj) ``` La première étape consiste à créer une liste contenant nos quatre tableaux, il est -conseillé de de donner un nom à chaque table. En faisant cela, il sera plus facile +conseillé de donner un nom à chaque table. En faisant cela, il sera plus facile de suivre le déroulement de la pose du secret secondaire. ```{r} @@ -280,7 +280,7 @@ Les noms de la liste doivent être identiques aux noms des tableaux présent dan Les modalités utilisées pour mentionner le total de chaque variable doivent être déclarées par l'utilisateur, dans une liste nominative. Toutefois, lorsque toutes -les variables ont la même modalité pour pour le total, l'information peut être +les variables ont la même modalité pour le total, l'information peut être spécifiée de la manière suivante : ```{r totcodes} @@ -289,8 +289,8 @@ total_codes <- "Total" ### Préparation des fichiers hiérarchiques -`ACTIVITY` et `NUTS` sont duex variables hiérarchiques.On utilise une table de -correspondance pour chacunes d'entre elles pour créer le fichier .hrc dont τ-Argus +`ACTIVITY` et `NUTS` sont deux variables hiérarchiques. On utilise une table de +correspondance pour chacune d'entre elles pour créer le fichier .hrc dont τ-Argus a besoin. ```{r corr_tables} diff --git a/vignettes/rtauargus.Rmd b/vignettes/rtauargus.Rmd index 5c5dd8d..9945e4e 100644 --- a/vignettes/rtauargus.Rmd +++ b/vignettes/rtauargus.Rmd @@ -1,512 +1,510 @@ ---- -title: "τ-Argus from R - tabular version" -subtitle:

![logo R](R_logo_small.png)![logo τ-Argus](TauBall2_small.png)
Package {rtauargus}

-output: - rmarkdown::html_vignette: - toc: true - toc_depth: 3 -vignette: > - %\VignetteIndexEntry{Tau-Argus from R - tabular version} - %\VignetteEngine{knitr::rmarkdown} - %\VignetteEncoding{UTF-8} ---- - - - - - - - - -``` r -library(dplyr) -``` - -## Introduction - -### Presentation of the package - -The _rtauargus_ package offers an **R** interface for **τ-Argus**. -It allows to : - -- create inputs (asc, tab and rda files) from R data; -- generate the sequence of instructions to be executed in batch mode (arb file); -- launch a batch τ-Argus ; -- retrieve the results in R. - -The syntax of some of the arguments closely matches the _batch_ syntax of -τ-Argus. This allows a large number of functions to be used without -multiplying the arguments of the functions. The package will also be able to adapt -more easily to possible modifications of the software (new -methods available, additional options...). -The syntax rules for writing batch are given in the τ-Argus reference manual and will be specified in a dedicated help section. - -> The package was developed on the basis of open source versions of τ-Argus (versions 4.2 and above), in particular the latest version available at the time of development (4.2.3). -> -> It is not compatible with version 3.5.**_ - -### Purpose of this document - -This document aims to explain the main functionalities of the package, -using relatively simple examples. -A detailed documentation of any function (exhaustive list of arguments, -technical aspects...) is available *via* the dedicated help section. - -

- summary ↑ -

- - - - - -## Setup - -The following setup should be made before the first use (and no longer afterwards) - -### τ-Argus - -_rtauargus_ fonctions using τ-Argus requires that the software can be used from the workstation. -The github repository of τ-Argus is here: [https://github.com/sdcTools/tauargus](https://github.com/sdcTools/tauargus). -The latest releases can be downloaded here: [https://github.com/sdcTools/tauargus/releases](https://github.com/sdcTools/tauargus/releases). - -### Dependencies - - _rtauargus_ requires some other R packages.Those are the dependencies to install. - - -``` -• purrr (>= 0.2) -• dplyr (>= 0.7) -• tidyr -• data.table -• gdata, -• stringr -• rlang -• zoo -• sdcHierarchies -• igraph -• lifecycle -``` -The package _rtauargus_ can be installed now. - -

- sommaire ↑ -

- - - - -## Quick Start - -This section explains how to perform a minimal configuration of the package and -how to apply suppressive methods in a single instruction. - -### Location of τ-Argus - -When loading the package, the console displays some information: - - -``` r -library(rtauargus) -``` - -In particular, a plausible location for the τ-Argus software is -predefined. This can be changed for the duration of the R session, as follows: - - -``` r -loc_tauargus <- "Y:/Logiciels/TauArgus/TauArgus4.2.3/TauArgus.exe" - -options(rtauargus.tauargus_exe = loc_tauargus) -``` - - -With this small adjustment done, the package is ready to be used. - -> _For a more customized configuration, see the specific vignettes_ - -### Protecting a single tabular data with `tab_rtauargus()` function - -The `tab_rtauargus()` function performs a full processing to protect the table and retrieves the results immediately in R. - -Completely abstracting from the inner workings of τ-Argus, it allows the entire processing to be made in a single instruction. All intermediate files are created in a local directory. - -`tab_rtauargus()` requires the following arguments : - -- `tabular`: a data.frame containing the table ; -- `dir_name`: the directory for the outputs; -- `files_name`: all the τ-Argus files will be named with it (different extensions); -- `explanatory_vars`: the name of all explanatory variables in `tabular`; -- `secret_var` or `safety_rules`: the way to apply primary suppression (explain later) -- `totcode`: the code for total of each explanatory variable in `tabular` - -All the arguments and their default options will be detailed ( where?). - -#### Minimal example - -For the following demonstration, a fictitious table will be used: - - -``` r -act_size <- - data.frame( - ACTIVITY = c("01","01","01","02","02","02","06","06","06","Total","Total","Total"), - SIZE = c("tr1","tr2","Total","tr1","tr2","Total","tr1","tr2","Total","tr1","tr2","Total"), - VAL = c(100,50,150,30,20,50,60,40,100,190,110,300), - N_OBS = c(10,5,15,2,5,7,8,6,14,20,16,36), - MAX = c(20,15,20,20,10,20,16,38,38,20,38,38) - ) -act_size -#> ACTIVITY SIZE VAL N_OBS MAX -#> 1 01 tr1 100 10 20 -#> 2 01 tr2 50 5 15 -#> 3 01 Total 150 15 20 -#> 4 02 tr1 30 2 20 -#> 5 02 tr2 20 5 10 -#> 6 02 Total 50 7 20 -#> 7 06 tr1 60 8 16 -#> 8 06 tr2 40 6 38 -#> 9 06 Total 100 14 38 -#> 10 Total tr1 190 20 20 -#> 11 Total tr2 110 16 38 -#> 12 Total Total 300 36 38 -``` - -As primary rules, we use the two following ones: - -- The n-k dominance rule with n=1 and k = 85 -- The minimum frequency rule with n = 3 and a safety range of 10. - -To get the results for the dominance rule, we need to specify the largest contributor to each cell, corresponding to the `MAX` variable in the tabular data. - - -``` r -ex1 <- tab_rtauargus( - act_size, - dir_name = "tauargus_files/ex1", - files_name = "ex1", - explanatory_vars = c("ACTIVITY","SIZE"), - safety_rules = "FREQ(3,10)|NK(1,85)", - value = "VAL", - freq = "N_OBS", - maxscore = "MAX", - totcode = c(ACTIVITY="Total",SIZE="Total") -) -#> Start of batch procedure; file: Z:\rtauargus\vignettes\tauargus_files\ex1\ex1.arb -#> "Z:\rtauargus\vignettes\tauargus_files\ex1\ex1.tab" -#> "Z:\rtauargus\vignettes\tauargus_files\ex1\ex1.rda" -#> "ACTIVITY""SIZE"|"VAL"|| -#> FREQ(3,10)|NK(1,85) -#> 1 -#> Tables have been read -#> MOD(1,5,1,0,0) -#> Start of the modular protection for table ACTIVITY x SIZE | VAL -#> End of modular protection. Time used 0 seconds -#> Number of suppressions: 2 -#> (1,4,,"Z:\rtauargus\vignettes\tauargus_files\ex1\ex1.csv") -#> Table: ACTIVITY x SIZE | VAL has been written -#> Output file name: Z:\rtauargus\vignettes\tauargus_files\ex1\ex1.csv -#> End of TauArgus run -``` - -By default, the function displays in the console the logbook content in which -user can read all steps run by τ-Argus. This can be retrieved in the logbook.txt file. With `verbose = FALSE`, the function can be silenced. - -By default, the function returns the original dataset with one variable more, -called `Status`, directly resulting from τ-Argus and describing the status of -each cell as follows: - --`A`: primary secret cell because of frequency rule; --`B`: primary secret cell because of dominance rule (1st contributor); --`C`: primary secret cell because of frequency rule (more contributors in case when n>1); --`D`: secondary secret cell; --`V`: valid cells - no need to mask. - - -``` r -ex1 -#> ACTIVITY SIZE VAL N_OBS MAX Status -#> 1 01 Total 150 15 20 V -#> 2 01 tr1 100 10 20 V -#> 3 01 tr2 50 5 15 V -#> 4 02 Total 50 7 20 V -#> 5 02 tr1 30 2 20 A -#> 6 02 tr2 20 5 10 D -#> 7 06 Total 100 14 38 V -#> 8 06 tr1 60 8 16 D -#> 9 06 tr2 40 6 38 B -#> 10 Total Total 300 36 38 V -#> 11 Total tr1 190 20 20 V -#> 12 Total tr2 110 16 38 V -``` - - -All the files generated by the function are written in the specified directory -(`dir_name` argument). The default format for the protected table is csv but it can be changed. All the τ-Argus files (.tab, .rda, .arb and .txt) are written in the -same directory, too. To go further, you can consult the latest version of the τ-Argus manual is downloadable here: -[https://research.cbs.nl/casc/Software/TauManualV4.1.pdf](https://research.cbs.nl/casc/Software/TauManualV4.1.pdf). - - -#### Example with hierarchy and primary secret already done - -##### Data - -For this example, we'd like to protect a table in which companies' turnover -is broken down by business sectors and size. To load the data, do: - - -``` r -data("turnover_act_size") -head(turnover_act_size) -#> # A tibble: 6 x 5 -#> ACTIVITY SIZE N_OBS TOT MAX -#> -#> 1 AZ Total 405 44475. 6212. -#> 2 BE Total 12878 24827613. 1442029. -#> 3 FZ Total 28043 8907311. 1065833. -#> 4 GI Total 62053 26962063. 3084242. -#> 5 JZ Total 8135 8584917. 3957364. -#> 6 KZ Total 8140 62556596. 10018017. -``` - -The meaning of each variable is: - --`ACTIVITY`: business sector, hierarchical variables with three levels described -in the `activity_corr_table` dataset. The root is noted "Total"; --`SIZE`: size of the companies (Number of employees in three categories -+ overall category "Total"); --`N_OBS`: Frequency, number of companies; --`TOT`: turnover value in euros; --`MAX`: turnover of the company which contributes the most to the cell. - -##### Hierarchy's file - -Before performing the `tab_rtauargus()` function, we have to prepare the hierarchical -information into the appropriate format for τ-Argus, *.i.e.* a `.hrc` file. -From a correspondence table, the `write_hrc2()` function does the job for you. - -Here, the correspondence table describes the nesting of the three levels of business -sectors, from the most aggregated to the least one: - - -``` r -data(activity_corr_table) -head(activity_corr_table) -#> A10 A21 A88 -#> 1 AZ A 01 -#> 2 AZ A 02 -#> 3 AZ X X -#> 4 BE B 06 -#> 5 BE B 07 -#> 6 BE B 08 -``` - - - -``` r -hrc_file_activity <- write_hrc2( - corr_table = activity_corr_table, - file_name = "hrc/activity.hrc" -) -``` - -##### Primary secret - -In this example, we'll apply the primary secret ourselves, *i.e.* not with the -help of τ-Argus. The idea is to use τ-Argus with an apriori file. -For that purpose, we create a boolean variable to specify -which cells don't comply with the primary secret rules. Using the same rules as before, -we get: - - -``` r -turnover_act_size <- turnover_act_size %>% - mutate( - is_secret_freq = N_OBS > 0 & N_OBS < 3, - is_secret_dom = MAX > TOT*0.85, - is_secret_prim = is_secret_freq | is_secret_dom - ) -``` - -##### Running τ-Argus - -Two arguments has to be added to the `tab_rtauargus()` function: - --`secret_var`, indicating the name of the variable in `tabular` containing the -primary secret (apriori) information; --`hrc`, indicating the name of the hierarchy file to use for `ACTIVITY` variable. - -Since the primary suppression was already specified, no need to use the arguments, -`safety_rules` and `maxscore`. The first one is set by default to "MAN(10)", so -as to say that a 10% Interval Protection is applied. - -By default, `tab_rtauargus()` runs the Modular method to perform the secondary secret. Here, we choose to use the Optimal method by changing the `suppress` argument. - - -``` r -ex2 <- tab_rtauargus( - turnover_act_size, - dir_name = "tauargus_files/ex2", - files_name = "ex2", - explanatory_vars = c("ACTIVITY","SIZE"), - value = "TOT", - freq = "N_OBS", - secret_var = "is_secret_prim", - hrc = c(ACTIVITY = hrc_file_activity), - totcode = c(ACTIVITY="Total",SIZE="Total"), - suppress = "OPT(1,5)", - verbose=FALSE -) -``` - -##### Result - - -``` r -str(ex2) -#> 'data.frame': 414 obs. of 9 variables: -#> $ ACTIVITY : chr "01" "01" "02" "02" ... -#> $ SIZE : chr "Total" "tr1" "Total" "tr1" ... -#> $ N_OBS : int 18 18 387 381 6 1 1 4 4 84 ... -#> $ TOT : num 853 853 43623 35503 8120 ... -#> $ MAX : num 303 303 6212 6212 4812 ... -#> $ is_secret_freq: logi FALSE FALSE FALSE FALSE FALSE TRUE ... -#> $ is_secret_dom : logi FALSE FALSE FALSE FALSE FALSE TRUE ... -#> $ is_secret_prim: logi FALSE FALSE FALSE FALSE FALSE TRUE ... -#> $ Status : chr "V" "V" "V" "V" ... -``` - - -``` r -table(ex2$Status) -#> -#> B D V -#> 77 64 273 -``` - -As we can see in the `table()` results, all the primary secret has the status "B" -in the output produced by τ-Argus. To adjust this, we can do: - - -``` r -ex2 %>% - mutate( - Status = dplyr::case_when( - is_secret_freq ~ "A", - TRUE ~ Status - ) - ) %>% - dplyr::count(Status) -#> Status n -#> 1 A 52 -#> 2 B 25 -#> 3 D 64 -#> 4 V 273 -``` - - -### Protecting several tables at the same time, with `tab_muli_manager()` function - -The function `tab_multi_manager()` can deal with a whole set of (linked or not) tables. -It is an iterating process, performing secondary suppression with one table at a time and it ensures that the common cells have the same status. When a common cell is concerned by secondary suppression, it reverberates the secret on each table that shares this common cell. The process ends when the secondary secret is consistent in every tables. See more details in vignettes *Manage the protection of linked tables* - -#### Data - -For this example, two tables will be used : - - -``` r -data("turnover_act_size") -data("turnover_act_cj") -str(turnover_act_cj) -#> tibble [406 x 5] (S3: tbl_df/tbl/data.frame) -#> $ ACTIVITY: chr [1:406] "AZ" "BE" "FZ" "GI" ... -#> $ CJ : chr [1:406] "Total" "Total" "Total" "Total" ... -#> $ N_OBS : int [1:406] 405 12878 28043 62053 8135 8140 11961 41359 26686 25108 ... -#> $ TOT : num [1:406] 44475 24827613 8907311 26962063 8584917 ... -#> $ MAX : num [1:406] 6212 1442029 1065833 3084242 3957364 ... -``` - -The second tabular dataset provides the turnover of companies broken down by -business sectors (`ACTIVITY`) and type of company (`CJ`). The latter has three -categories and the overall category is noted "Total". - -Since the two tables share one common explanatory variable (`ACTIVITY`), they can't be treated separately without risk of inconsistent protection. - -#### Primary secret - -The first step consists in indicating whether each cell complies with the primary rules, -or not. A boolean variable is created, equal to TRUE if the cell doesn't comply. - -Here, we use the same rules as previously. - - -``` r -list_data_2_tabs <- list( - act_size = turnover_act_size, - act_cj = turnover_act_cj -) %>% - purrr::map( - function(df){ - df %>% - mutate( - is_secret_freq = N_OBS > 0 & N_OBS < 3, - is_secret_dom = MAX > TOT*0.85, - is_secret_prim = is_secret_freq | is_secret_dom - ) - } - ) -``` - - -#### Running τ-Argus - -Now that the primary secret has been specified for both tables, we can run the process. - - -``` r -ex3 <- tab_multi_manager( - list_tables = list_data_2_tabs, - list_explanatory_vars = list( - act_size = c("ACTIVITY", "SIZE"), - act_cj = c("ACTIVITY", "CJ") - ), - hrc = c(ACTIVITY = hrc_file_activity), - dir_name = "tauargus_files/ex3", - value = "TOT", - freq = "N_OBS", - secret_var = "is_secret_prim", - totcode = "Total" -) -#> --- Current table to treat: act_size --- -#> --- Current table to treat: act_cj --- -#> --- Current table to treat: act_size --- -``` - -By default, the function uses a wrapper of `tab_rtauargus()` function, called `tab_rtauargus2()`, to apply secondary secret with τ-Argus. Many default parameters are set. In particular: - -- Interval Protection fixed to 10; -- Suppress method set to "MOD(1,5,1,0,0); -- Output. - -When running, the function displays at each iteration which table is treated. - -The vignette *Manage the protection of linked tables* provides a full presentation -of `tab_multi_manager()` function. - -#### About this vignette - -- Authors: **Julien Jamme** & **Nathanael Rastout** -- Last update: **17/02/2025** -- Version of rtauargus used: **1.2.999** -- Version of τ-Argus used : **TauArgus 4.2.3** -- R version used : **4.3.3** - -

- summary ↑ -

+--- +title: "τ-Argus from R - tabular version" +subtitle:

![logo R](R_logo_small.png)![logo τ-Argus](TauBall2_small.png)
Package {rtauargus}

+output: + rmarkdown::html_vignette: + toc: true + toc_depth: 3 +vignette: > + %\VignetteIndexEntry{Tau-Argus from R - tabular version} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + + + + + + + + +``` r +library(dplyr) +``` + +## Introduction + +### Presentation of the package + +The _rtauargus_ package offers an **R** interface for **τ-Argus**. +It allows to : + +- create inputs (asc, tab and rda files) from R data; +- generate the sequence of instructions to be executed in batch mode (arb file); +- launch a batch τ-Argus ; +- retrieve the results in R. + +The syntax of some of the arguments closely matches the _batch_ syntax of +τ-Argus. This allows a large number of functions to be used without +multiplying the arguments of the functions. The package will also be able to adapt +more easily to possible modifications of the software (new +methods available, additional options...). +The syntax rules for writing batch are given in the τ-Argus reference manual and will be specified in a dedicated help section. + +> The package was developed on the basis of open source versions of τ-Argus (versions 4.2 and above), in particular the latest version available at the time of development (4.2.3). +> +> It is not compatible with version 3.5.**_ + +### Purpose of this document + +This document aims to explain the main functionalities of the package, +using relatively simple examples. +A detailed documentation of any function (exhaustive list of arguments, +technical aspects...) is available *via* the dedicated help section. + +

+ summary ↑ +

+ + + + + +## Setup + +The following setup should be made before the first use (and no longer afterwards) + +### τ-Argus + +_rtauargus_ fonctions using τ-Argus require that the software can be used from the workstation. +The github repository of τ-Argus is here: [https://github.com/sdcTools/tauargus](https://github.com/sdcTools/tauargus). +The latest releases can be downloaded here: [https://github.com/sdcTools/tauargus/releases](https://github.com/sdcTools/tauargus/releases). + +### Dependencies + + _rtauargus_ requires some other R packages.Those are the dependencies to install. + + +``` +• purrr (>= 0.2), +• dplyr (>= 0.7), +• tidyr, +• data.table, +• gdata, +• stringr, +• rlang, +• zoo, +• sdcHierarchies, +• igraph, +• lifecycle +``` +The package _rtauargus_ can be installed now. + +

+ sommaire ↑ +

+ + + + +## Quick Start + +This section explains how to perform a minimal configuration of the package and +how to apply suppressive methods in a single instruction. + +### Location of τ-Argus + +When loading the package, the console displays some information: + + +``` r +library(rtauargus) +``` + +In particular, a plausible location for the τ-Argus software is +predefined. This can be changed for the duration of the R session, as follows: + + +``` r +loc_tauargus <- "Y:/Logiciels/TauArgus/TauArgus4.2.3/TauArgus.exe" + +options(rtauargus.tauargus_exe = loc_tauargus) +``` + + +With this small adjustment done, the package is ready to be used. + +> _For a more customized configuration, see the specific vignettes_ + +### Protecting a single tabular data with `tab_rtauargus()` function + +The `tab_rtauargus()` function performs a full processing to protect the table and retrieves the results immediately in R. + +Completely abstracting from the inner workings of τ-Argus, it allows the entire processing to be made in a single instruction. All intermediate files are created in a local directory. + +`tab_rtauargus()` requires the following arguments : + +- `tabular`: a data.frame containing the table ; +- `dir_name`: the directory for the outputs; +- `files_name`: all the τ-Argus files will be named with it (different extensions); +- `explanatory_vars`: the name of all explanatory variables in `tabular`; +- `secret_var` or `safety_rules`: the way to apply primary suppression (explain later) +- `totcode`: the code for total of each explanatory variable in `tabular` + +All the arguments and their default options will be detailed ( where?). + +#### Minimal example + +For the following demonstration, a fictitious table will be used: + + +``` r +act_size <- + data.frame( + ACTIVITY = c("01","01","01","02","02","02","06","06","06","Total","Total","Total"), + SIZE = c("tr1","tr2","Total","tr1","tr2","Total","tr1","tr2","Total","tr1","tr2","Total"), + VAL = c(100,50,150,30,20,50,60,40,100,190,110,300), + N_OBS = c(10,5,15,2,5,7,8,6,14,20,16,36), + MAX = c(20,15,20,20,10,20,16,38,38,20,38,38) + ) +act_size +#> ACTIVITY SIZE VAL N_OBS MAX +#> 1 01 tr1 100 10 20 +#> 2 01 tr2 50 5 15 +#> 3 01 Total 150 15 20 +#> 4 02 tr1 30 2 20 +#> 5 02 tr2 20 5 10 +#> 6 02 Total 50 7 20 +#> 7 06 tr1 60 8 16 +#> 8 06 tr2 40 6 38 +#> 9 06 Total 100 14 38 +#> 10 Total tr1 190 20 20 +#> 11 Total tr2 110 16 38 +#> 12 Total Total 300 36 38 +``` + +As primary rules, we use the two following ones: + +- The n-k dominance rule with n=1 and k = 85 +- The minimum frequency rule with n = 3 and a safety range of 10. + +To get the results for the dominance rule, we need to specify the largest contributor to each cell, corresponding to the `MAX` variable in the tabular data. + + +``` r +ex1 <- tab_rtauargus( + act_size, + dir_name = "tauargus_files/ex1", + files_name = "ex1", + explanatory_vars = c("ACTIVITY","SIZE"), + safety_rules = "FREQ(3,10)|NK(1,85)", + value = "VAL", + freq = "N_OBS", + maxscore = "MAX", + totcode = c(ACTIVITY="Total",SIZE="Total") +) +#> Start of batch procedure; file: Z:\confidentialite\rtauargus\vignettes\tauargus_files\ex1\ex1.arb +#> "Z:\confidentialite\rtauargus\vignettes\tauargus_files\ex1\ex1.tab" +#> "Z:\confidentialite\rtauargus\vignettes\tauargus_files\ex1\ex1.rda" +#> "ACTIVITY""SIZE"|"VAL"|| +#> FREQ(3,10)|NK(1,85) +#> 1 +#> Tables have been read +#> MOD(1,5,1,0,0) +#> Start of the modular protection for table ACTIVITY x SIZE | VAL +#> End of modular protection. Time used 0 seconds +#> Number of suppressions: 2 +#> (1,4,,"Z:\confidentialite\rtauargus\vignettes\tauargus_files\ex1\ex1.csv") +#> Table: ACTIVITY x SIZE | VAL has been written +#> Output file name: Z:\confidentialite\rtauargus\vignettes\tauargus_files\ex1\ex1.csv +#> End of TauArgus run +``` + +By default, the function displays in the console the logbook content in which +user can read all steps run by τ-Argus. This can be retrieved in the logbook.txt file. With `verbose = FALSE`, the function can be silenced. + +By default, the function returns the original dataset with one variable more, +called `Status`, directly resulting from τ-Argus and describing the status of +each cell as follows: + +-`A`: primary secret cell because of frequency rule; +-`B`: primary secret cell because of dominance rule (1st contributor); +-`C`: primary secret cell because of frequency rule (more contributors in case when n>1); +-`D`: secondary secret cell; +-`V`: valid cells - no need to mask. + + +``` r +ex1 +#> ACTIVITY SIZE VAL N_OBS MAX Status +#> 1 01 Total 150 15 20 V +#> 2 01 tr1 100 10 20 V +#> 3 01 tr2 50 5 15 V +#> 4 02 Total 50 7 20 V +#> 5 02 tr1 30 2 20 A +#> 6 02 tr2 20 5 10 D +#> 7 06 Total 100 14 38 V +#> 8 06 tr1 60 8 16 D +#> 9 06 tr2 40 6 38 B +#> 10 Total Total 300 36 38 V +#> 11 Total tr1 190 20 20 V +#> 12 Total tr2 110 16 38 V +``` + + +All the files generated by the function are written in the specified directory +(`dir_name` argument). The default format for the protected table is csv but it can be changed. All the τ-Argus files (.tab, .rda, .arb and .txt) are written in the +same directory, too. To go further, you can consult the latest version of the τ-Argus manual is downloadable here: +[https://research.cbs.nl/casc/Software/TauManualV4.1.pdf](https://research.cbs.nl/casc/Software/TauManualV4.1.pdf). + + +#### Example with hierarchy and primary secret already done + +##### Data + +For this example, we'd like to protect a table in which companies' turnover +is broken down by business sectors and size. To load the data, do: + + +``` r +data("turnover_act_size") +head(turnover_act_size) +#> # A tibble: 6 x 5 +#> ACTIVITY SIZE N_OBS TOT MAX +#> +#> 1 AZ Total 405 44475. 6212. +#> 2 BE Total 12878 24827613. 1442029. +#> 3 FZ Total 28043 8907311. 1065833. +#> 4 GI Total 62053 26962063. 3084242. +#> 5 JZ Total 8135 8584917. 3957364. +#> 6 KZ Total 8140 62556596. 10018017. +``` + +The meaning of each variable is: + +-`ACTIVITY`: business sector, hierarchical variables with three levels described +in the `activity_corr_table` dataset. The root is noted "Total"; +-`SIZE`: size of the companies (Number of employees in three categories ++ overall category "Total"); +-`N_OBS`: Frequency, number of companies; +-`TOT`: turnover value in euros; +-`MAX`: turnover of the company which contributes the most to the cell. + +##### Hierarchy's file + +Before performing the `tab_rtauargus()` function, we have to prepare the hierarchical +information into the appropriate format for τ-Argus, *.i.e.* a `.hrc` file. +From a correspondence table, the `write_hrc2()` function does the job for you. + +Here, the correspondence table describes the nesting of the three levels of business +sectors, from the most aggregated to the least one: + + +``` r +data(activity_corr_table) +head(activity_corr_table) +#> A10 A21 A88 +#> 1 AZ A 01 +#> 2 AZ A 02 +#> 3 AZ X X +#> 4 BE B 06 +#> 5 BE B 07 +#> 6 BE B 08 +``` + + + +``` r +hrc_file_activity <- write_hrc2( + corr_table = activity_corr_table, + file_name = "hrc/activity.hrc" +) +``` + +##### Primary secret + +In this example, we'll apply the primary secret ourselves, *i.e.* not with the +help of τ-Argus. The idea is to use τ-Argus with an apriori file. +For that purpose, we create a boolean variable to specify +which cells don't comply with the primary secret rules. Using the same rules as before, +we get: + + +``` r +turnover_act_size <- turnover_act_size %>% + mutate( + is_secret_freq = N_OBS > 0 & N_OBS < 3, + is_secret_dom = MAX > TOT*0.85, + is_secret_prim = is_secret_freq | is_secret_dom + ) +``` + +##### Running τ-Argus + +Two arguments has to be added to the `tab_rtauargus()` function: + +-`secret_var`, indicating the name of the variable in `tabular` containing the +primary secret (apriori) information; +-`hrc`, indicating the name of the hierarchy file to use for `ACTIVITY` variable. + +Since the primary suppression was already specified, no need to use the arguments, +`safety_rules` and `maxscore`. The first one is set by default to "MAN(10)", so +as to say that a 10% Interval Protection is applied. + +By default, `tab_rtauargus()` runs the Modular method to perform the secondary secret. Here, we choose to use the Optimal method by changing the `suppress` argument. + + +``` r +ex2 <- tab_rtauargus( + turnover_act_size, + dir_name = "tauargus_files/ex2", + files_name = "ex2", + explanatory_vars = c("ACTIVITY","SIZE"), + value = "TOT", + freq = "N_OBS", + secret_var = "is_secret_prim", + hrc = c(ACTIVITY = hrc_file_activity), + totcode = c(ACTIVITY="Total",SIZE="Total"), + suppress = "OPT(1,5)", + verbose=FALSE +) +``` + +##### Result + + +``` r +str(ex2) +#> 'data.frame': 414 obs. of 9 variables: +#> $ ACTIVITY : chr "01" "01" "02" "02" ... +#> $ SIZE : chr "Total" "tr1" "Total" "tr1" ... +#> $ N_OBS : int 18 18 387 381 6 1 1 4 4 84 ... +#> $ TOT : num 853 853 43623 35503 8120 ... +#> $ MAX : num 303 303 6212 6212 4812 ... +#> $ is_secret_freq: logi FALSE FALSE FALSE FALSE FALSE TRUE ... +#> $ is_secret_dom : logi FALSE FALSE FALSE FALSE FALSE TRUE ... +#> $ is_secret_prim: logi FALSE FALSE FALSE FALSE FALSE TRUE ... +#> $ Status : chr "V" "V" "V" "V" ... +``` + + +``` r +table(ex2$Status) +#> +#> B D V +#> 77 64 273 +``` + +As we can see in the `table()` results, all the primary secret has the status "B" +in the output produced by τ-Argus. To adjust this, we can do: + + +``` r +ex2 %>% + mutate( + Status = dplyr::case_when( + is_secret_freq ~ "A", + TRUE ~ Status + ) + ) %>% + dplyr::count(Status) +#> Status n +#> 1 A 52 +#> 2 B 25 +#> 3 D 64 +#> 4 V 273 +``` + + +### Protecting several tables at the same time, with `tab_multi_manager()` function + +The function `tab_multi_manager()` can deal with a whole set of (linked or not) tables. +It is an iterating process, performing secondary suppression with one table at a time and it ensures that the common cells have the same status. When a common cell is concerned by secondary suppression, it reverberates the secret on each table that shares this common cell. The process ends when the secondary secret is consistent in every tables. See more details in vignettes *Manage the protection of linked tables* + +#### Data + +For this example, two tables will be used : + + +``` r +data("turnover_act_size") +data("turnover_act_cj") +str(turnover_act_cj) +#> tibble [406 x 5] (S3: tbl_df/tbl/data.frame) +#> $ ACTIVITY: chr [1:406] "AZ" "BE" "FZ" "GI" ... +#> $ CJ : chr [1:406] "Total" "Total" "Total" "Total" ... +#> $ N_OBS : int [1:406] 405 12878 28043 62053 8135 8140 11961 41359 26686 25108 ... +#> $ TOT : num [1:406] 44475 24827613 8907311 26962063 8584917 ... +#> $ MAX : num [1:406] 6212 1442029 1065833 3084242 3957364 ... +``` + +The second tabular dataset provides the turnover of companies broken down by +business sectors (`ACTIVITY`) and type of company (`CJ`). The latter has three +categories and the overall category is noted "Total". + +Since the two tables share one common explanatory variable (`ACTIVITY`), they can't be treated separately without risk of inconsistent protection. + +#### Primary secret + +The first step consists in indicating whether each cell complies with the primary rules, +or not. A boolean variable is created, equal to TRUE if the cell doesn't comply. + +Here, we use the same rules as previously. + + +``` r +list_data_2_tabs <- list( + act_size = turnover_act_size, + act_cj = turnover_act_cj +) %>% + purrr::map( + function(df){ + df %>% + mutate( + is_secret_freq = N_OBS > 0 & N_OBS < 3, + is_secret_dom = MAX > TOT*0.85, + is_secret_prim = is_secret_freq | is_secret_dom + ) + } + ) +``` + + +#### Running τ-Argus + +Now that the primary secret has been specified for both tables, we can run the process. + + +``` r +ex3 <- tab_multi_manager( + list_tables = list_data_2_tabs, + list_explanatory_vars = list( + act_size = c("ACTIVITY", "SIZE"), + act_cj = c("ACTIVITY", "CJ") + ), + hrc = c(ACTIVITY = hrc_file_activity), + dir_name = "tauargus_files/ex3", + value = "TOT", + freq = "N_OBS", + secret_var = "is_secret_prim", + totcode = "Total" +) +#> --- Current table to treat: act_size | loop iter : 1 --- --- Current table to treat: act_cj | loop iter : 2 --- --- Current table to treat: act_size | loop iter : 3 --- +``` + +By default, the function uses a wrapper of `tab_rtauargus()` function, called `tab_rtauargus2()`, to apply secondary secret with τ-Argus. Many default parameters are set. In particular: + +- Interval Protection fixed to 10; +- Suppress method set to "MOD(1,5,1,0,0); +- Output. + +When running, the function displays at each iteration which table is treated. + +The vignette *Manage the protection of linked tables* provides a full presentation +of `tab_multi_manager()` function. + +#### About this vignette + +- Authors: **Julien Jamme** & **Nathanael Rastout** +- Last update: **27/10/2026** +- Version of rtauargus used: **1.3.6** +- Version of τ-Argus used : **TauArgus 4.2.3** +- R version used : **4.5.3** + +

+ summary ↑ +

diff --git a/vignettes/rtauargus.Rmd.orig b/vignettes/rtauargus.Rmd.orig index 94a7e11..5f4acfb 100644 --- a/vignettes/rtauargus.Rmd.orig +++ b/vignettes/rtauargus.Rmd.orig @@ -76,7 +76,7 @@ The following setup should be made before the first use (and no longer afterward ### τ-Argus -_rtauargus_ fonctions using τ-Argus requires that the software can be used from the workstation. +_rtauargus_ fonctions using τ-Argus require that the software can be used from the workstation. The github repository of τ-Argus is here: [https://github.com/sdcTools/tauargus](https://github.com/sdcTools/tauargus). The latest releases can be downloaded here: [https://github.com/sdcTools/tauargus/releases](https://github.com/sdcTools/tauargus/releases). @@ -318,7 +318,7 @@ ex2 %>% ``` -### Protecting several tables at the same time, with `tab_muli_manager()` function +### Protecting several tables at the same time, with `tab_multi_manager()` function The function `tab_multi_manager()` can deal with a whole set of (linked or not) tables. It is an iterating process, performing secondary suppression with one table at a time and it ensures that the common cells have the same status. When a common cell is concerned by secondary suppression, it reverberates the secret on each table that shares this common cell. The process ends when the secondary secret is consistent in every tables. See more details in vignettes *Manage the protection of linked tables* diff --git a/vignettes/rtauargus_fr.Rmd b/vignettes/rtauargus_fr.Rmd index e133996..dcf7555 100644 --- a/vignettes/rtauargus_fr.Rmd +++ b/vignettes/rtauargus_fr.Rmd @@ -1,512 +1,510 @@ ---- -title: "Tau-Argus depuis R - données tabulées" -subtitle:

![logo R](R_logo_small.png)![logo τ-Argus](TauBall2_small.png)
Package {rtauargus}

-output: - rmarkdown::html_vignette: - toc: true - toc_depth: 3 -vignette: > - %\VignetteIndexEntry{Tau-Argus depuis R - données tabulées} - %\VignetteEngine{knitr::rmarkdown} - %\VignetteEncoding{UTF-8} ---- - - - - - - - - -``` r -library(dplyr) -``` - -## Introduction - -### Présentation du package - -Le package _rtauargus_ offre une interface **R** pour **τ-Argus**. -Il permet de : - -- créer des input (fichiers asc, tab et rda) à partir de données R ; -- de générer la séquence d'instructions à exécuter en mode batch (fichier arb) ; -- lancer un batch τ-Argus ; -- récupérer les résultats dans R. - -La syntaxe de certains des arguments correspond étroitement à la syntaxe _batch_ de -τ-Argus. Cela permet d'utiliser un nombre important de fonctions sans -multiplier les arguments des fonctions. Le package pourra également s'adapter -plus facilement aux éventuelles modifications du logiciel (nouveaux -algorithmes disponibles, options supplémentaires...). -Les règles de syntaxes d'écriture du batch sont détaillés dans le manuel de référence de τ-Argus et sont égalements précisées dans la vignette *options_safety_rules*. - -> Le package a été développé sur la base de versions open source de τ-Argus (versions 4.2 et supérieures), en particulier la dernière version disponible au moment du développement (4.2.3). -> -> Il n'est pas compatible avec la version 3.5.**_. - -### But de ce document - -Ce document a pour but d'expliquer les principales fonctionnalités du package, -en utilisant des exemples relativement simples. -Une documentation détaillée de toute fonction (liste exhaustive des arguments, -aspects techniques...) est disponible *via* la section d'aide dédiée. - -

- summary ↑ -

- - - - - -## Configuration - -Le paramétrage suivant doit être fait avant la première utilisation (et plus après). - -### τ-Argus - -_rtauargus_ fonctions utilisant τ-Argus nécessite que le logiciel puisse être utilisé depuis le poste de travail. -Le dépôt github de τ-Argus est ici : [https://github.com/sdcTools/tauargus](https://github.com/sdcTools/tauargus). -Les dernières versions peuvent être téléchargées ici : [https://github.com/sdcTools/tauargus/releases](https://github.com/sdcTools/tauargus/releases). - -### Dépendances - -_rtauargus_ nécessite quelques autres packages R. Voici les dépendances à installer. - - -``` -• purrr (>= 0.2) -• dplyr (>= 0.7) -• tidyr -• data.table -• gdata, -• stringr -• rlang -• zoo -• sdcHierarchies -• igraph -• lifecycle -``` -Le package _rtauargus_ peut être installé maintenant. - -

- summary ↑ -

- - - - -## Prise en main - -Cette section explique comment effectuer une configuration minimale du package et -comment appliquer des méthodes de suppression en une seule instruction. - -### Location de τ-Argus - -Lors du chargement du package, la console affiche quelques informations : - - -``` r -library(rtauargus) -``` - -En particulier, un emplacement plausible pour le logiciel τ-Argus est -prédéfini. Celui-ci peut être modifié pour la durée de la session R, comme suit : - - - -``` r -loc_tauargus <- "Y:/Logiciels/TauArgus/TauArgus4.2.3/TauArgus.exe" - -options(rtauargus.tauargus_exe = loc_tauargus) -``` - - -Une fois ce petit ajustement effectué, le package est prêt à être utilisé. - -> _Pour une configuration plus personnalisée, voir les vignettes spécifiques_. - -### Protéger un seul tableau avec la fonction `tab_rtauargus()`. - -La fonction `tab_rtauargus()` effectue un traitement complet pour protéger le tableau et récupère immédiatement les résultats dans R. - -En s'abstrayant complètement du fonctionnement interne de τ-Argus, elle permet de réaliser l'ensemble des traitements en une seule instruction. Tous les fichiers intermédiaires sont créés dans un répertoire local. - -`tab_rtauargus()` requiert les arguments suivants : - -- `tabular` : un data.frame contenant le tableau ; -- `dir_name` : le répertoire pour les sorties ; -- `files_name` : tous les fichiers τ-Argus seront nommés ainsi(différentes extensions) ; -- `explanatory_vars` : le nom de toutes les variables explicatives dans `tabular` ; -- `secret_var` ou `safety_rules` : la manière d'appliquer la suppression primaire (expliqué plus tard) -- `totcode` : le code pour le total de chaque variable explicative dans `tabular`. - -Tous les arguments et leurs options par défaut seront détaillés ( où ?). - -#### Exemple minimal - -Pour la présentation un tableau fictif sera utilisé : - - - -``` r -act_size <- - data.frame( - ACTIVITY = c("01","01","01","02","02","02","06","06","06","Total","Total","Total"), - SIZE = c("tr1","tr2","Total","tr1","tr2","Total","tr1","tr2","Total","tr1","tr2","Total"), - VAL = c(100,50,150,30,20,50,60,40,100,190,110,300), - N_OBS = c(10,5,15,2,5,7,8,6,14,20,16,36), - MAX = c(20,15,20,20,10,20,16,38,38,20,38,38) - ) -act_size -#> ACTIVITY SIZE VAL N_OBS MAX -#> 1 01 tr1 100 10 20 -#> 2 01 tr2 50 5 15 -#> 3 01 Total 150 15 20 -#> 4 02 tr1 30 2 20 -#> 5 02 tr2 20 5 10 -#> 6 02 Total 50 7 20 -#> 7 06 tr1 60 8 16 -#> 8 06 tr2 40 6 38 -#> 9 06 Total 100 14 38 -#> 10 Total tr1 190 20 20 -#> 11 Total tr2 110 16 38 -#> 12 Total Total 300 36 38 -``` - -Nous utiliserons ces deux règles de secret primaire : - -- La règle de dominance n-k avec n=1 et k = 85. -- La règle de fréquence minimale avec n = 3 et un intervalle de protection à 10%. - -Pour obtenir les résultats de la règle de dominance, nous devons spécifier le plus grand contributeur de chaque cellule, correspondant à la variable `MAX` dans les données tabulées. - - -``` r -ex1 <- tab_rtauargus( - act_size, - dir_name = "tauargus_files/ex1", - files_name = "ex1", - explanatory_vars = c("ACTIVITY","SIZE"), - safety_rules = "FREQ(3,10)|NK(1,85)", - value = "VAL", - freq = "N_OBS", - maxscore = "MAX", - totcode = c(ACTIVITY="Total",SIZE="Total") -) -#> Start of batch procedure; file: Z:\rtauargus\vignettes\tauargus_files\ex1\ex1.arb -#> "Z:\rtauargus\vignettes\tauargus_files\ex1\ex1.tab" -#> "Z:\rtauargus\vignettes\tauargus_files\ex1\ex1.rda" -#> "ACTIVITY""SIZE"|"VAL"|| -#> FREQ(3,10)|NK(1,85) -#> 1 -#> Tables have been read -#> MOD(1,5,1,0,0) -#> Start of the modular protection for table ACTIVITY x SIZE | VAL -#> End of modular protection. Time used 0 seconds -#> Number of suppressions: 2 -#> (1,4,,"Z:\rtauargus\vignettes\tauargus_files\ex1\ex1.csv") -#> Table: ACTIVITY x SIZE | VAL has been written -#> Output file name: Z:\rtauargus\vignettes\tauargus_files\ex1\ex1.csv -#> End of TauArgus run -``` - -Par défaut, la fonction affiche dans la console le contenu du journal de bord dans lequel -l'utilisateur peut lire toutes les étapes exécutées par τ-Argus. Ceci peut être récupéré dans le fichier logbook.txt. Avec `verbose = FALSE`, les étapes seront seulement conservées dans le journal. - -Par défaut, la fonction renvoie le tableau fournit en entrée avec une variable de plus -appelée `Status`, issue directement de τ-Argus et décrivant le statut de -chaque cellule comme suit : - --`A` : cellule en secret primaire en raison de la règle de fréquence ; --`B` : cellule en secret primaire en raison de la règle de dominance (1er contributeur) ; --`C` : cellule en secret primaire en raison de la règle de dominance(plus de contributeurs dans le cas où n>1) ; --`D` : cellule en secret secondaire ; --`V` : cellules valides - pas besoin de masquer. - - -``` r -ex1 -#> ACTIVITY SIZE VAL N_OBS MAX Status -#> 1 01 Total 150 15 20 V -#> 2 01 tr1 100 10 20 V -#> 3 01 tr2 50 5 15 V -#> 4 02 Total 50 7 20 V -#> 5 02 tr1 30 2 20 A -#> 6 02 tr2 20 5 10 D -#> 7 06 Total 100 14 38 V -#> 8 06 tr1 60 8 16 D -#> 9 06 tr2 40 6 38 B -#> 10 Total Total 300 36 38 V -#> 11 Total tr1 190 20 20 V -#> 12 Total tr2 110 16 38 V -``` - - -Tous les fichiers générés par la fonction sont écrits dans le répertoire spécifié -(argument `dir_name`). Le format par défaut du tableau protégé est csv mais il peut être modifié. Tous les fichiers τ-Argus (.tab, .rda, .arb et .txt) sont écrits dans le même répertoire. Pour aller plus loin, vous pouvez consulter la dernière version du manuel de τ-Argus téléchargeable ici : -[https://research.cbs.nl/casc/Software/TauManualV4.1.pdf](https://research.cbs.nl/casc/Software/TauManualV4.1.pdf). - - -#### Exemple avec une hiérarchie et pose du secret primaire via R - -##### Données - -Dans cet exemple, nous souhaitons protéger un tableau dans lequel le chiffre d'affaires des entreprises est ventilé par secteur d'activité et par taille. Pour charger les données : - - -``` r -data("turnover_act_size") -head(turnover_act_size) -#> # A tibble: 6 x 5 -#> ACTIVITY SIZE N_OBS TOT MAX -#> -#> 1 AZ Total 405 44475. 6212. -#> 2 BE Total 12878 24827613. 1442029. -#> 3 FZ Total 28043 8907311. 1065833. -#> 4 GI Total 62053 26962063. 3084242. -#> 5 JZ Total 8135 8584917. 3957364. -#> 6 KZ Total 8140 62556596. 10018017. -``` - -La signification de chaque variable est la suivante : - --`ACTIVITY` : secteur d'activité, variables hiérarchiques à trois niveaux décrites -dans l'ensemble de données `activity_corr_table`. La racine est notée "Total" ; --`SIZE` : taille des entreprises (Nombre d'employés dans trois modalités -+ la marge "Total") ; --`N_OBS` : Fréquence, nombre d'entreprises ; --`TOT` : valeur du chiffre d'affaires en euros ; --`MAX` : chiffre d'affaires de l'entreprise qui contribue le plus à la cellule. - -##### Fichier hiérarchique - -Avant d'exécuter la fonction `tab_rtauargus()`, nous devons renseigner les imbrications de la hiérarchie dans le format approprié pour τ-Argus, *.i.e.* un fichier `.hrc`. -A partir d'un tableau de correspondance, la fonction `write_hrc2()` fait le travail pour vous. - -Ici, le tableau de correspondance décrit l'imbrication des trois niveaux de secteurs d'activité, du plus agrégé au moins agrégé : - - -``` r -data(activity_corr_table) -head(activity_corr_table) -#> A10 A21 A88 -#> 1 AZ A 01 -#> 2 AZ A 02 -#> 3 AZ X X -#> 4 BE B 06 -#> 5 BE B 07 -#> 6 BE B 08 -``` - - -``` r -hrc_file_activity <- write_hrc2( - corr_table = activity_corr_table, - file_name = "hrc/activity.hrc" -) -``` - -##### Secret primaire - -Dans cet exemple, nous appliquerons nous-mêmes le secret primaire, *c'est-à-dire* sans -l'aide de τ-Argus. L'idée est d'utiliser τ-Argus avec un fichier apriori (.hst). Qui permet de spécifier directement au logiciel quelles cellules sont à placer en secret primaire. -Pour cela, nous créons une variable booléenne pour spécifier -quelles cellules ne respectent pas les règles du secret primaire. En utilisant les mêmes règles que précédemment, -on obtient : - - - -``` r -turnover_act_size <- turnover_act_size %>% - mutate( - is_secret_freq = N_OBS > 0 & N_OBS < 3, - is_secret_dom = MAX > TOT*0.85, - is_secret_prim = is_secret_freq | is_secret_dom - ) -``` - -##### Exécution de τ-Argus - -Deux arguments doivent être ajoutés à la fonction `tab_rtauargus()` : - --`secret_var`, indiquant le nom de la variable dans `tabular` qui renseigne le secret primaire ; --`hrc`, indiquant le nom du fichier hiérarchique à utiliser pour la variable `ACTIVITY`. - -Puisque le secret primaire a été spécifié, il n'est pas nécessaire d'utiliser les arguments, -`safety_rules` et `maxscore`. Le premier est fixé par défaut à "MAN(10)", afin d'appliquer un intervalle de protection à 10%. - -Par défaut, `tab_rtauargus()` exécute la méthode Modular pour effectuer le secret secondaire. Ici, nous choisissons d'utiliser la méthode Optimal en modifiant l'argument `suppress`. - - - -``` r -ex2 <- tab_rtauargus( - turnover_act_size, - dir_name = "tauargus_files/ex2", - files_name = "ex2", - explanatory_vars = c("ACTIVITY","SIZE"), - value = "TOT", - freq = "N_OBS", - secret_var = "is_secret_prim", - hrc = c(ACTIVITY = hrc_file_activity), - totcode = c(ACTIVITY="Total",SIZE="Total"), - suppress = "OPT(1,5)", - verbose=FALSE -) -``` - -##### Résultat - - -``` r -str(ex2) -#> 'data.frame': 414 obs. of 9 variables: -#> $ ACTIVITY : chr "01" "01" "02" "02" ... -#> $ SIZE : chr "Total" "tr1" "Total" "tr1" ... -#> $ N_OBS : int 18 18 387 381 6 1 1 4 4 84 ... -#> $ TOT : num 853 853 43623 35503 8120 ... -#> $ MAX : num 303 303 6212 6212 4812 ... -#> $ is_secret_freq: logi FALSE FALSE FALSE FALSE FALSE TRUE ... -#> $ is_secret_dom : logi FALSE FALSE FALSE FALSE FALSE TRUE ... -#> $ is_secret_prim: logi FALSE FALSE FALSE FALSE FALSE TRUE ... -#> $ Status : chr "V" "V" "V" "V" ... -``` - - -``` r -table(ex2$Status) -#> -#> B D V -#> 77 64 273 -``` - -Comme on peut le voir dans les résultats du `table()`,dans la sortie produite par τ-Argus tous les secrets primaires ont le statut "B". -Pour corriger cela, nous pouvons faire : - - -``` r -ex2 %>% - mutate( - Status = dplyr::case_when( - is_secret_freq ~ "A", - TRUE ~ Status - ) - ) %>% - dplyr::count(Status) -#> Status n -#> 1 A 52 -#> 2 B 25 -#> 3 D 64 -#> 4 V 273 -``` - - -### Protéger plusieurs tableaux en même temps, avec la fonction `tab_muli_manager()`. - -La fonction `tab_multi_manager()` permet de traiter un ensemble de tableaux (liés ou non). -C'est un processus itératif, qui effectue la pose de secret secondaire d'un tableau à la fois et qui s'assure que les cellules communes ont le même statut. Lorsqu'une cellule commune est concernée par le secret secondaire, elle répercute le secret sur chaque tableau qui partage cette cellule commune. Le processus se termine lorsque le secret secondaire est cohérent pour tous les tableaux. Voir plus de détails dans les vignettes *Gérer la protection des tableaux liés*. - -#### Données - -Pour cet exemple, deux tableaux seront utilisés : - - - -``` r -data("turnover_act_size") -data("turnover_act_cj") -str(turnover_act_cj) -#> tibble [406 x 5] (S3: tbl_df/tbl/data.frame) -#> $ ACTIVITY: chr [1:406] "AZ" "BE" "FZ" "GI" ... -#> $ CJ : chr [1:406] "Total" "Total" "Total" "Total" ... -#> $ N_OBS : int [1:406] 405 12878 28043 62053 8135 8140 11961 41359 26686 25108 ... -#> $ TOT : num [1:406] 44475 24827613 8907311 26962063 8584917 ... -#> $ MAX : num [1:406] 6212 1442029 1065833 3084242 3957364 ... -``` - - -Le deuxième tableau fournit le chiffre d'affaires des entreprises ventilé par -secteurs d'activité (`ACTIVITY`) et par type d'entreprise (`CJ`). - -Les deux tableaux ayant une variable explicative commune (`ACTIVITY`), ils ne peuvent être traités séparément sans générer risque de rupture du secret secondaire. - -#### Secret primaire - -La première étape consiste à indiquer si chaque cellule respecte les règles primaires, -ou non. Une variable booléenne est créée, égale à TRUE si la cellule n'est pas conforme. - -Ici, on utilise les mêmes règles que précédemment. - - - -``` r -list_data_2_tabs <- list( - act_size = turnover_act_size, - act_cj = turnover_act_cj -) %>% - purrr::map( - function(df){ - df %>% - mutate( - is_secret_freq = N_OBS > 0 & N_OBS < 3, - is_secret_dom = MAX > TOT*0.85, - is_secret_prim = is_secret_freq | is_secret_dom - ) - } - ) -``` - - -#### Exécution de τ-Argus - -Maintenant que le secret primaire a été spécifié pour les deux tableaux, nous pouvons lancer le processus. - - - -``` r -ex3 <- tab_multi_manager( - list_tables = list_data_2_tabs, - list_explanatory_vars = list( - act_size = c("ACTIVITY", "SIZE"), - act_cj = c("ACTIVITY", "CJ") - ), - hrc = c(ACTIVITY = hrc_file_activity), - dir_name = "tauargus_files/ex3", - value = "TOT", - freq = "N_OBS", - secret_var = "is_secret_prim", - totcode = "Total" -) -#> --- Current table to treat: act_size --- -#> --- Current table to treat: act_cj --- -#> --- Current table to treat: act_size --- -``` - -Par défaut, la fonction utilise un wrapper de la fonction `tab_rtauargus()`, appelé `tab_rtauargus2()`, pour appliquer le secret secondaire avec τ-Argus. De nombreux paramètres par défaut sont définis. En particulier : - -- Intervalle de protection fixé à 10 ; -- Méthode de suppression fixée à "MOD(1,5,1,0,0) ; -- Output au format csv. - -Lors de son exécution, la fonction affiche à chaque itération quel tableau est traité. - -La vignette *Gérer la protection des tableaux liés* fournit une présentation complète -de la fonction `tab_multi_manager()`. - -#### Détail de la vignette - -- Authors: **Julien Jamme** & **Nathanael Rastout** -- Last update: **17/02/2025** -- Version of rtauargus used: **1.2.999** -- Version of τ-Argus used : **TauArgus 4.2.3** -- R version used : **4.3.3** - -

- summary ↑ -

+--- +title: "Tau-Argus depuis R - données tabulées" +subtitle:

![logo R](R_logo_small.png)![logo τ-Argus](TauBall2_small.png)
Package {rtauargus}

+output: + rmarkdown::html_vignette: + toc: true + toc_depth: 3 +vignette: > + %\VignetteIndexEntry{Tau-Argus depuis R - données tabulées} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + + + + + + + + +``` r +library(dplyr) +``` + +## Introduction + +### Présentation du package + +Le package _rtauargus_ offre une interface **R** pour **τ-Argus**. +Il permet de : + +- créer des input (fichiers asc, tab et rda) à partir de données R ; +- de générer la séquence d'instructions à exécuter en mode batch (fichier arb) ; +- lancer un batch τ-Argus ; +- récupérer les résultats dans R. + +La syntaxe de certains des arguments correspond étroitement à la syntaxe _batch_ de +τ-Argus. Cela permet d'utiliser un nombre important de fonctions sans +multiplier les arguments des fonctions. Le package pourra également s'adapter +plus facilement aux éventuelles modifications du logiciel (nouveaux +algorithmes disponibles, options supplémentaires...). +Les règles de syntaxes d'écriture du batch sont détaillées dans le manuel de référence de τ-Argus et sont également précisées dans la vignette *options_safety_rules*. + +> Le package a été développé sur la base de versions open source de τ-Argus (versions 4.2 et supérieures), en particulier la dernière version disponible au moment du développement (4.2.3). +> +> Il n'est pas compatible avec la version 3.5.**_. + +### But de ce document + +Ce document a pour but d'expliquer les principales fonctionnalités du package, +en utilisant des exemples relativement simples. +Une documentation détaillée de toute fonction (liste exhaustive des arguments, +aspects techniques...) est disponible *via* la section d'aide dédiée. + +

+ summary ↑ +

+ + + + + +## Configuration + +Le paramétrage suivant doit être fait avant la première utilisation (et plus après). + +### τ-Argus + +_rtauargus_ fonctions utilisant τ-Argus nécessite que le logiciel puisse être utilisé depuis le poste de travail. +Le dépôt github de τ-Argus est ici : [https://github.com/sdcTools/tauargus](https://github.com/sdcTools/tauargus). +Les dernières versions peuvent être téléchargées ici : [https://github.com/sdcTools/tauargus/releases](https://github.com/sdcTools/tauargus/releases). + +### Dépendances + +_rtauargus_ nécessite quelques autres packages R. Voici les dépendances à installer. + + +``` +• purrr (>= 0.2), +• dplyr (>= 0.7), +• tidyr, +• data.table, +• gdata, +• stringr, +• rlang, +• zoo, +• sdcHierarchies, +• igraph, +• lifecycle +``` +Le package _rtauargus_ peut être installé maintenant. + +

+ summary ↑ +

+ + + + +## Prise en main + +Cette section explique comment effectuer une configuration minimale du package et +comment appliquer des méthodes de suppression en une seule instruction. + +### Location de τ-Argus + +Lors du chargement du package, la console affiche quelques informations : + + +``` r +library(rtauargus) +``` + +En particulier, un emplacement plausible pour le logiciel τ-Argus est +prédéfini. Celui-ci peut être modifié pour la durée de la session R, comme suit : + + + +``` r +loc_tauargus <- "Y:/Logiciels/TauArgus/TauArgus4.2.3/TauArgus.exe" + +options(rtauargus.tauargus_exe = loc_tauargus) +``` + + +Une fois ce petit ajustement effectué, le package est prêt à être utilisé. + +> _Pour une configuration plus personnalisée, voir les vignettes spécifiques_. + +### Protéger un seul tableau avec la fonction `tab_rtauargus()`. + +La fonction `tab_rtauargus()` effectue un traitement complet pour protéger le tableau et récupère immédiatement les résultats dans R. + +En s'abstrayant complètement du fonctionnement interne de τ-Argus, elle permet de réaliser l'ensemble des traitements en une seule instruction. Tous les fichiers intermédiaires sont créés dans un répertoire local. + +`tab_rtauargus()` requiert les arguments suivants : + +- `tabular` : un data.frame contenant le tableau ; +- `dir_name` : le répertoire pour les sorties ; +- `files_name` : tous les fichiers τ-Argus seront nommés ainsi(différentes extensions) ; +- `explanatory_vars` : le nom de toutes les variables explicatives dans `tabular` ; +- `secret_var` ou `safety_rules` : la manière d'appliquer la suppression primaire (expliqué plus tard) +- `totcode` : le code pour le total de chaque variable explicative dans `tabular`. + +Tous les arguments et leurs options par défaut seront détaillés ( où ?). + +#### Exemple minimal + +Pour la présentation un tableau fictif sera utilisé : + + + +``` r +act_size <- + data.frame( + ACTIVITY = c("01","01","01","02","02","02","06","06","06","Total","Total","Total"), + SIZE = c("tr1","tr2","Total","tr1","tr2","Total","tr1","tr2","Total","tr1","tr2","Total"), + VAL = c(100,50,150,30,20,50,60,40,100,190,110,300), + N_OBS = c(10,5,15,2,5,7,8,6,14,20,16,36), + MAX = c(20,15,20,20,10,20,16,38,38,20,38,38) + ) +act_size +#> ACTIVITY SIZE VAL N_OBS MAX +#> 1 01 tr1 100 10 20 +#> 2 01 tr2 50 5 15 +#> 3 01 Total 150 15 20 +#> 4 02 tr1 30 2 20 +#> 5 02 tr2 20 5 10 +#> 6 02 Total 50 7 20 +#> 7 06 tr1 60 8 16 +#> 8 06 tr2 40 6 38 +#> 9 06 Total 100 14 38 +#> 10 Total tr1 190 20 20 +#> 11 Total tr2 110 16 38 +#> 12 Total Total 300 36 38 +``` + +Nous utiliserons ces deux règles de secret primaire : + +- La règle de dominance n-k avec n=1 et k = 85. +- La règle de fréquence minimale avec n = 3 et un intervalle de protection à 10%. + +Pour obtenir les résultats de la règle de dominance, nous devons spécifier le plus grand contributeur de chaque cellule, correspondant à la variable `MAX` dans les données tabulées. + + +``` r +ex1 <- tab_rtauargus( + act_size, + dir_name = "tauargus_files/ex1", + files_name = "ex1", + explanatory_vars = c("ACTIVITY","SIZE"), + safety_rules = "FREQ(3,10)|NK(1,85)", + value = "VAL", + freq = "N_OBS", + maxscore = "MAX", + totcode = c(ACTIVITY="Total",SIZE="Total") +) +#> Start of batch procedure; file: Z:\confidentialite\rtauargus\vignettes\tauargus_files\ex1\ex1.arb +#> "Z:\confidentialite\rtauargus\vignettes\tauargus_files\ex1\ex1.tab" +#> "Z:\confidentialite\rtauargus\vignettes\tauargus_files\ex1\ex1.rda" +#> "ACTIVITY""SIZE"|"VAL"|| +#> FREQ(3,10)|NK(1,85) +#> 1 +#> Tables have been read +#> MOD(1,5,1,0,0) +#> Start of the modular protection for table ACTIVITY x SIZE | VAL +#> End of modular protection. Time used 0 seconds +#> Number of suppressions: 2 +#> (1,4,,"Z:\confidentialite\rtauargus\vignettes\tauargus_files\ex1\ex1.csv") +#> Table: ACTIVITY x SIZE | VAL has been written +#> Output file name: Z:\confidentialite\rtauargus\vignettes\tauargus_files\ex1\ex1.csv +#> End of TauArgus run +``` + +Par défaut, la fonction affiche dans la console le contenu du journal de bord dans lequel +l'utilisateur peut lire toutes les étapes exécutées par τ-Argus. Ceci peut être récupéré dans le fichier logbook.txt. Avec `verbose = FALSE`, les étapes seront seulement conservées dans le journal. + +Par défaut, la fonction renvoie le tableau fournit en entrée avec une variable de plus +appelée `Status`, issue directement de τ-Argus et décrivant le statut de +chaque cellule comme suit : + +-`A` : cellule en secret primaire en raison de la règle de fréquence ; +-`B` : cellule en secret primaire en raison de la règle de dominance (1er contributeur) ; +-`C` : cellule en secret primaire en raison de la règle de dominance(plus de contributeurs dans le cas où n>1) ; +-`D` : cellule en secret secondaire ; +-`V` : cellules valides - pas besoin de masquer. + + +``` r +ex1 +#> ACTIVITY SIZE VAL N_OBS MAX Status +#> 1 01 Total 150 15 20 V +#> 2 01 tr1 100 10 20 V +#> 3 01 tr2 50 5 15 V +#> 4 02 Total 50 7 20 V +#> 5 02 tr1 30 2 20 A +#> 6 02 tr2 20 5 10 D +#> 7 06 Total 100 14 38 V +#> 8 06 tr1 60 8 16 D +#> 9 06 tr2 40 6 38 B +#> 10 Total Total 300 36 38 V +#> 11 Total tr1 190 20 20 V +#> 12 Total tr2 110 16 38 V +``` + + +Tous les fichiers générés par la fonction sont écrits dans le répertoire spécifié +(argument `dir_name`). Le format par défaut du tableau protégé est csv mais il peut être modifié. Tous les fichiers τ-Argus (.tab, .rda, .arb et .txt) sont écrits dans le même répertoire. Pour aller plus loin, vous pouvez consulter la dernière version du manuel de τ-Argus téléchargeable ici : +[https://research.cbs.nl/casc/Software/TauManualV4.1.pdf](https://research.cbs.nl/casc/Software/TauManualV4.1.pdf). + + +#### Exemple avec une hiérarchie et pose du secret primaire via R + +##### Données + +Dans cet exemple, nous souhaitons protéger un tableau dans lequel le chiffre d'affaires des entreprises est ventilé par secteur d'activité et par taille. Pour charger les données : + + +``` r +data("turnover_act_size") +head(turnover_act_size) +#> # A tibble: 6 x 5 +#> ACTIVITY SIZE N_OBS TOT MAX +#> +#> 1 AZ Total 405 44475. 6212. +#> 2 BE Total 12878 24827613. 1442029. +#> 3 FZ Total 28043 8907311. 1065833. +#> 4 GI Total 62053 26962063. 3084242. +#> 5 JZ Total 8135 8584917. 3957364. +#> 6 KZ Total 8140 62556596. 10018017. +``` + +La signification de chaque variable est la suivante : + +-`ACTIVITY` : secteur d'activité, variables hiérarchiques à trois niveaux décrites +dans l'ensemble de données `activity_corr_table`. La racine est notée "Total" ; +-`SIZE` : taille des entreprises (Nombre d'employés dans trois modalités ++ la marge "Total") ; +-`N_OBS` : Fréquence, nombre d'entreprises ; +-`TOT` : valeur du chiffre d'affaires en euros ; +-`MAX` : chiffre d'affaires de l'entreprise qui contribue le plus à la cellule. + +##### Fichier hiérarchique + +Avant d'exécuter la fonction `tab_rtauargus()`, nous devons renseigner les imbrications de la hiérarchie dans le format approprié pour τ-Argus, *.i.e.* un fichier `.hrc`. +A partir d'un tableau de correspondance, la fonction `write_hrc2()` fait le travail pour vous. + +Ici, le tableau de correspondance décrit l'imbrication des trois niveaux de secteurs d'activité, du plus agrégé au moins agrégé : + + +``` r +data(activity_corr_table) +head(activity_corr_table) +#> A10 A21 A88 +#> 1 AZ A 01 +#> 2 AZ A 02 +#> 3 AZ X X +#> 4 BE B 06 +#> 5 BE B 07 +#> 6 BE B 08 +``` + + +``` r +hrc_file_activity <- write_hrc2( + corr_table = activity_corr_table, + file_name = "hrc/activity.hrc" +) +``` + +##### Secret primaire + +Dans cet exemple, nous appliquerons nous-mêmes le secret primaire, *c'est-à-dire* sans +l'aide de τ-Argus. L'idée est d'utiliser τ-Argus avec un fichier apriori (.hst). Qui permet de spécifier directement au logiciel quelles cellules sont à placer en secret primaire. +Pour cela, nous créons une variable booléenne pour spécifier +quelles cellules ne respectent pas les règles du secret primaire. En utilisant les mêmes règles que précédemment, +on obtient : + + + +``` r +turnover_act_size <- turnover_act_size %>% + mutate( + is_secret_freq = N_OBS > 0 & N_OBS < 3, + is_secret_dom = MAX > TOT*0.85, + is_secret_prim = is_secret_freq | is_secret_dom + ) +``` + +##### Exécution de τ-Argus + +Deux arguments doivent être ajoutés à la fonction `tab_rtauargus()` : + +-`secret_var`, indiquant le nom de la variable dans `tabular` qui renseigne le secret primaire ; +-`hrc`, indiquant le nom du fichier hiérarchique à utiliser pour la variable `ACTIVITY`. + +Puisque le secret primaire a été spécifié, il n'est pas nécessaire d'utiliser les arguments, +`safety_rules` et `maxscore`. Le premier est fixé par défaut à "MAN(10)", afin d'appliquer un intervalle de protection à 10%. + +Par défaut, `tab_rtauargus()` exécute la méthode Modular pour effectuer le secret secondaire. Ici, nous choisissons d'utiliser la méthode Optimal en modifiant l'argument `suppress`. + + + +``` r +ex2 <- tab_rtauargus( + turnover_act_size, + dir_name = "tauargus_files/ex2", + files_name = "ex2", + explanatory_vars = c("ACTIVITY","SIZE"), + value = "TOT", + freq = "N_OBS", + secret_var = "is_secret_prim", + hrc = c(ACTIVITY = hrc_file_activity), + totcode = c(ACTIVITY="Total",SIZE="Total"), + suppress = "OPT(1,5)", + verbose=FALSE +) +``` + +##### Résultat + + +``` r +str(ex2) +#> 'data.frame': 414 obs. of 9 variables: +#> $ ACTIVITY : chr "01" "01" "02" "02" ... +#> $ SIZE : chr "Total" "tr1" "Total" "tr1" ... +#> $ N_OBS : int 18 18 387 381 6 1 1 4 4 84 ... +#> $ TOT : num 853 853 43623 35503 8120 ... +#> $ MAX : num 303 303 6212 6212 4812 ... +#> $ is_secret_freq: logi FALSE FALSE FALSE FALSE FALSE TRUE ... +#> $ is_secret_dom : logi FALSE FALSE FALSE FALSE FALSE TRUE ... +#> $ is_secret_prim: logi FALSE FALSE FALSE FALSE FALSE TRUE ... +#> $ Status : chr "V" "V" "V" "V" ... +``` + + +``` r +table(ex2$Status) +#> +#> B D V +#> 77 64 273 +``` + +Comme on peut le voir dans les résultats du `table()`,dans la sortie produite par τ-Argus tous les secrets primaires ont le statut "B". +Pour corriger cela, nous pouvons faire : + + +``` r +ex2 %>% + mutate( + Status = dplyr::case_when( + is_secret_freq ~ "A", + TRUE ~ Status + ) + ) %>% + dplyr::count(Status) +#> Status n +#> 1 A 52 +#> 2 B 25 +#> 3 D 64 +#> 4 V 273 +``` + + +### Protéger plusieurs tableaux en même temps, avec la fonction `tab_multi_manager()`. + +La fonction `tab_multi_manager()` permet de traiter un ensemble de tableaux (liés ou non). +C'est un processus itératif, qui effectue la pose de secret secondaire d'un tableau à la fois et qui s'assure que les cellules communes ont le même statut. Lorsqu'une cellule commune est concernée par le secret secondaire, elle répercute le secret sur chaque tableau qui partage cette cellule commune. Le processus se termine lorsque le secret secondaire est cohérent pour tous les tableaux. Voir plus de détails dans les vignettes *Gérer la protection des tableaux liés*. + +#### Données + +Pour cet exemple, deux tableaux seront utilisés : + + + +``` r +data("turnover_act_size") +data("turnover_act_cj") +str(turnover_act_cj) +#> tibble [406 x 5] (S3: tbl_df/tbl/data.frame) +#> $ ACTIVITY: chr [1:406] "AZ" "BE" "FZ" "GI" ... +#> $ CJ : chr [1:406] "Total" "Total" "Total" "Total" ... +#> $ N_OBS : int [1:406] 405 12878 28043 62053 8135 8140 11961 41359 26686 25108 ... +#> $ TOT : num [1:406] 44475 24827613 8907311 26962063 8584917 ... +#> $ MAX : num [1:406] 6212 1442029 1065833 3084242 3957364 ... +``` + + +Le deuxième tableau fournit le chiffre d'affaires des entreprises ventilé par +secteurs d'activité (`ACTIVITY`) et par type d'entreprise (`CJ`). + +Les deux tableaux ayant une variable explicative commune (`ACTIVITY`), ils ne peuvent être traités séparément sans générer risque de rupture du secret secondaire. + +#### Secret primaire + +La première étape consiste à indiquer si chaque cellule respecte les règles primaires, +ou non. Une variable booléenne est créée, égale à TRUE si la cellule n'est pas conforme. + +Ici, on utilise les mêmes règles que précédemment. + + + +``` r +list_data_2_tabs <- list( + act_size = turnover_act_size, + act_cj = turnover_act_cj +) %>% + purrr::map( + function(df){ + df %>% + mutate( + is_secret_freq = N_OBS > 0 & N_OBS < 3, + is_secret_dom = MAX > TOT*0.85, + is_secret_prim = is_secret_freq | is_secret_dom + ) + } + ) +``` + + +#### Exécution de τ-Argus + +Maintenant que le secret primaire a été spécifié pour les deux tableaux, nous pouvons lancer le processus. + + + +``` r +ex3 <- tab_multi_manager( + list_tables = list_data_2_tabs, + list_explanatory_vars = list( + act_size = c("ACTIVITY", "SIZE"), + act_cj = c("ACTIVITY", "CJ") + ), + hrc = c(ACTIVITY = hrc_file_activity), + dir_name = "tauargus_files/ex3", + value = "TOT", + freq = "N_OBS", + secret_var = "is_secret_prim", + totcode = "Total" +) +#> --- Current table to treat: act_size | loop iter : 1 --- --- Current table to treat: act_cj | loop iter : 2 --- --- Current table to treat: act_size | loop iter : 3 --- +``` + +Par défaut, la fonction utilise un wrapper de la fonction `tab_rtauargus()`, appelé `tab_rtauargus2()`, pour appliquer le secret secondaire avec τ-Argus. De nombreux paramètres par défaut sont définis. En particulier : + +- Intervalle de protection fixé à 10 ; +- Méthode de suppression fixée à "MOD(1,5,1,0,0) ; +- Output au format csv. + +Lors de son exécution, la fonction affiche à chaque itération quel tableau est traité. + +La vignette *Gérer la protection des tableaux liés* fournit une présentation complète +de la fonction `tab_multi_manager()`. + +#### Détail de la vignette + +- Authors: **Julien Jamme** & **Nathanael Rastout** +- Last update: **27/10/2026** +- Version of rtauargus used: **1.3.6** +- Version of τ-Argus used : **TauArgus 4.2.3** +- R version used : **4.5.3** + +

+ summary ↑ +

diff --git a/vignettes/rtauargus_fr.Rmd.orig b/vignettes/rtauargus_fr.Rmd.orig index da1e1f5..d2e08ee 100644 --- a/vignettes/rtauargus_fr.Rmd.orig +++ b/vignettes/rtauargus_fr.Rmd.orig @@ -49,7 +49,7 @@ La syntaxe de certains des arguments correspond étroitement à la syntaxe _batc multiplier les arguments des fonctions. Le package pourra également s'adapter plus facilement aux éventuelles modifications du logiciel (nouveaux algorithmes disponibles, options supplémentaires...). -Les règles de syntaxes d'écriture du batch sont détaillés dans le manuel de référence de τ-Argus et sont égalements précisées dans la vignette *options_safety_rules*. +Les règles de syntaxes d'écriture du batch sont détaillées dans le manuel de référence de τ-Argus et sont également précisées dans la vignette *options_safety_rules*. > Le package a été développé sur la base de versions open source de τ-Argus (versions 4.2 et supérieures), en particulier la dernière version disponible au moment du développement (4.2.3). > @@ -315,7 +315,7 @@ ex2 %>% ``` -### Protéger plusieurs tableaux en même temps, avec la fonction `tab_muli_manager()`. +### Protéger plusieurs tableaux en même temps, avec la fonction `tab_multi_manager()`. La fonction `tab_multi_manager()` permet de traiter un ensemble de tableaux (liés ou non). C'est un processus itératif, qui effectue la pose de secret secondaire d'un tableau à la fois et qui s'assure que les cellules communes ont le même statut. Lorsqu'une cellule commune est concernée par le secret secondaire, elle répercute le secret sur chaque tableau qui partage cette cellule commune. Le processus se termine lorsque le secret secondaire est cohérent pour tous les tableaux. Voir plus de détails dans les vignettes *Gérer la protection des tableaux liés*. diff --git a/vignettes/rtauargus_micro.Rmd b/vignettes/rtauargus_micro.Rmd index 211b5d9..5d46838 100644 --- a/vignettes/rtauargus_micro.Rmd +++ b/vignettes/rtauargus_micro.Rmd @@ -42,7 +42,7 @@ in a modular way. They allow the integration of tasks performed by The syntax of some of the arguments closely matches the _batch_ syntax of τ-Argus. This allows you to use a large number of features without -multiply the arguments of the functions. The package can also be adapted to +multiplying the arguments of the functions. The package can also be adapted to more easily to possible modifications of the software (new available methods, additional options...). Syntax rules for the batch writing are in the reference manual of τ-Argus. @@ -116,16 +116,16 @@ To work, _rtauargus_ depends on other R packages. These have to be installed bef ``` -- purrr (>= 0.2) -- dplyr (>= 0.7) -- tidyr -- data.table +- purrr (>= 0.2), +- dplyr (>= 0.7), +- tidyr, +- data.table, - gdata, -- stringr -- rlang -- zoo -- sdcHierarchies -- igraph +- stringr, +- rlang, +- zoo, +- sdcHierarchies, +- igraph, - lifecycle ``` @@ -201,13 +201,13 @@ micro_rtauargus( safety_rules = "FREQ(3,10)", suppress = "GH(1,100)" ) -#> Start of batch procedure; file: C:\Users\KQCFFL\AppData\Local\Temp\Rtmpm05wlj\RTA_13aa85f527816.arb -#> "C:\Users\KQCFFL\AppData\Local\Temp\Rtmpm05wlj\RTA_13aa866f06f26.asc" -#> "C:\Users\KQCFFL\AppData\Local\Temp\Rtmpm05wlj\RTA_13aa866f06f26.rda" +#> Start of batch procedure; file: C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e87f223e1a.arb +#> "C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e872ba4592.asc" +#> "C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e872ba4592.rda" #> "V1"|""|| #> FREQ(3,10) #> -#> Start explore file: C:\Users\KQCFFL\AppData\Local\Temp\Rtmpm05wlj\RTA_13aa866f06f26.asc +#> Start explore file: C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e872ba4592.asc #> Start computing tables #> Table: V1 | has been specified #> Tables have been computed @@ -219,9 +219,9 @@ micro_rtauargus( #> Number of suppressions: 1 #> The hypercube procedure has been applied #> 1 cells have been suppressed -#> (1,4,AS+SE+,"C:\Users\KQCFFL\AppData\Local\Temp\Rtmpm05wlj\RTA_13aa826e25069.sbs") +#> (1,4,,"C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e87868754c.sbs") #> Table: V1 | has been written -#> Output file name: C:\Users\KQCFFL\AppData\Local\Temp\Rtmpm05wlj\RTA_13aa826e25069.sbs +#> Output file name: C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e87868754c.sbs #> End of TauArgus run #> NULL ``` @@ -254,15 +254,15 @@ secret1 <- output_options = c("", "AS+"), # no status for the 1st array show_batch_console = FALSE # to hide the log ) -#> Start of batch procedure; file: C:\Users\KQCFFL\AppData\Local\Temp\Rtmpm05wlj\RTA_13aa821eb5b19.arb -#> "C:\Users\KQCFFL\AppData\Local\Temp\Rtmpm05wlj\RTA_13aa85d87423f.asc" -#> "C:\Users\KQCFFL\AppData\Local\Temp\Rtmpm05wlj\RTA_13aa85d87423f.rda" +#> Start of batch procedure; file: C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e87b4b16fb.arb +#> "C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e86746587e.asc" +#> "C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e86746587e.rda" #> "V1"|""|| #> FREQ(3,10) #> "V1""V2"|""|| #> FREQ(3,10) #> -#> Start explore file: C:\Users\KQCFFL\AppData\Local\Temp\Rtmpm05wlj\RTA_13aa85d87423f.asc +#> Start explore file: C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e86746587e.asc #> Start computing tables #> Table: V1 | has been specified #> Table: V1 x V2 | has been specified @@ -275,22 +275,19 @@ secret1 <- #> Number of suppressions: 1 #> The hypercube procedure has been applied #> 1 cells have been suppressed -#> (1,4,,"C:\Users\KQCFFL\AppData\Local\Temp\Rtmpm05wlj\RTA_13aa861ea459a.sbs") +#> (1,4,,"C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e841576cef.sbs") #> Table: V1 | has been written -#> Output file name: C:\Users\KQCFFL\AppData\Local\Temp\Rtmpm05wlj\RTA_13aa861ea459a.sbs +#> Output file name: C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e841576cef.sbs #> GH(2,100) #> Start of the hypercube protection for table V1 x V2 | #> End of hypercube protection. Time used 1 seconds #> Number of suppressions: 2 #> The hypercube procedure has been applied #> 2 cells have been suppressed -#> (2,4,AS+,"C:\Users\KQCFFL\AppData\Local\Temp\Rtmpm05wlj\RTA_13aa844945238.sbs") +#> (2,4,AS+,"C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e841517919.sbs") #> Table: V1 x V2 | has been written -#> Output file name: C:\Users\KQCFFL\AppData\Local\Temp\Rtmpm05wlj\RTA_13aa844945238.sbs +#> Output file name: C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e841517919.sbs #> End of TauArgus run -``` - -``` r secret1 #> NULL @@ -409,6 +406,7 @@ micro_asc_rda( totcode = c("Ensemble", V2 = "TOTAL"), decimals = 1 ) + ``` Content of the files created : @@ -450,10 +448,10 @@ in a temporary folder. It is possible to retrieve the location and name names_asc_rda <- micro_asc_rda(microdata) names_asc_rda #> $asc_filename -#> [1] "C:\\Users\\KQCFFL\\AppData\\Local\\Temp\\Rtmpm05wlj\\RTA_13aa875d56ea.asc" +#> [1] "C:\\Users\\YR4UKQ\\AppData\\Local\\Temp\\RtmpKSzpVY\\RTA_110e8b894422.asc" #> #> $rda_filename -#> [1] "C:\\Users\\KQCFFL\\AppData\\Local\\Temp\\Rtmpm05wlj\\RTA_13aa875d56ea.rda" +#> [1] "C:\\Users\\YR4UKQ\\AppData\\Local\\Temp\\RtmpKSzpVY\\RTA_110e8b894422.rda" ```

@@ -500,14 +498,14 @@ file.show("Z:/microdata.arb", pager = "internal") ``` // Batch generated by package *rtauargus* -// (2025-02-17 12:14:22 CET) +// (2026-10-27 15:41:15 CET) "Z:\microdata.asc" "Z:\microdata.rda" "V1"|""|| FREQ(3,10) GH(1,100) - (1,4,AS+SE+,"Z:\results\secretV1.csv") + (1,4,,"Z:\results\secretV1.csv") ``` #### Elaborate example @@ -545,14 +543,14 @@ file.show("Z:/microdata.arb", pager = "internal") ``` // Batch generated by package *rtauargus* -// (2025-02-17 12:14:22 CET) +// (2026-10-27 15:41:15 CET) "Z:\microdata.asc" "Z:\microdata.rda" "V1"|""|| FREQ(3,10) GH(1,100) - (1,4,AS+SE+,"Z:\results\secretV1.csv") + (1,4,,"Z:\results\secretV1.csv") ``` #### Temporary files @@ -574,11 +572,11 @@ infos_arb <- ) infos_arb #> $arb_filename -#> [1] "C:\\Users\\KQCFFL\\AppData\\Local\\Temp\\Rtmpm05wlj\\RTA_13aa83d136448.arb" +#> [1] "C:\\Users\\YR4UKQ\\AppData\\Local\\Temp\\RtmpKSzpVY\\RTA_110e8da69be.arb" #> #> $output_names -#> [1] "C:\\Users\\KQCFFL\\AppData\\Local\\Temp\\Rtmpm05wlj\\RTA_13aa81a11772c.sbs" -#> [2] "C:\\Users\\KQCFFL\\AppData\\Local\\Temp\\Rtmpm05wlj\\RTA_13aa822675f41.sbs" +#> [1] "C:\\Users\\YR4UKQ\\AppData\\Local\\Temp\\RtmpKSzpVY\\RTA_110e81af67592.sbs" +#> [2] "C:\\Users\\YR4UKQ\\AppData\\Local\\Temp\\RtmpKSzpVY\\RTA_110e8452079c1.sbs" ```

@@ -613,13 +611,10 @@ secret2 <- run_arb("Z:/microdata.arb", missing_dir = "create") #> Number of suppressions: 1 #> The hypercube procedure has been applied #> 1 cells have been suppressed -#> (1,4,AS+SE+,"Z:\results\secretV1.csv") +#> (1,4,,"Z:\results\secretV1.csv") #> Table: V1 | has been written #> Output file name: Z:\results\secretV1.csv #> End of TauArgus run -``` - -``` r secret2 #> NULL @@ -637,7 +632,7 @@ also available: - `tauargus_exe` : to change the executable (override the `rtauargus.tauargus_exe` the time of the function) ; - `logbook` : location and name of the file containing the error log; -- show_batch_on_console` : to display or not the batch progress in the +- `show_batch_on_console` : to display or not the batch progress in the console ; - `import` : if disabled, the function only generates text files without importing them into R (see next section for details). @@ -783,7 +778,7 @@ rtauargus_options() #> [1] "stop" #> #> $rtauargus.output_options -#> [1] "AS+SE+" +#> [1] "" #> #> $rtauargus.output_type #> [1] "4" @@ -955,10 +950,10 @@ For any return or error report, please use - Author: **Pierre-Yves Berrard** - Updated by: **Julien Jamme** -- Last update: **17/02/2025** -- Version of rtauargus used: **1.2.999** +- Last update: **27/10/2026** +- Version of rtauargus used: **1.3.6** - Version of τ-Argus used : **TauArgus 4.2.3** -- R version used : **4.3.3** +- R version used : **4.5.3**

summary ↑ diff --git a/vignettes/rtauargus_micro.Rmd.orig b/vignettes/rtauargus_micro.Rmd.orig index bb3c27a..4448406 100644 --- a/vignettes/rtauargus_micro.Rmd.orig +++ b/vignettes/rtauargus_micro.Rmd.orig @@ -49,7 +49,7 @@ in a modular way. They allow the integration of tasks performed by The syntax of some of the arguments closely matches the _batch_ syntax of τ-Argus. This allows you to use a large number of features without -multiply the arguments of the functions. The package can also be adapted to +multiplying the arguments of the functions. The package can also be adapted to more easily to possible modifications of the software (new available methods, additional options...). Syntax rules for the batch writing are in the reference manual of τ-Argus. @@ -466,7 +466,7 @@ also available: - `tauargus_exe` : to change the executable (override the `rtauargus.tauargus_exe` the time of the function) ; - `logbook` : location and name of the file containing the error log; -- show_batch_on_console` : to display or not the batch progress in the +- `show_batch_on_console` : to display or not the batch progress in the console ; - `import` : if disabled, the function only generates text files without importing them into R (see next section for details). diff --git a/vignettes/rtauargus_micro_fr.Rmd b/vignettes/rtauargus_micro_fr.Rmd index d8a6c6d..58313c4 100644 --- a/vignettes/rtauargus_micro_fr.Rmd +++ b/vignettes/rtauargus_micro_fr.Rmd @@ -117,16 +117,16 @@ installer au préalable (entre parenthèses les versions minimales requises). ``` -• purrr (>= 0.2) -• dplyr (>= 0.7) -• tidyr -• data.table +• purrr (>= 0.2), +• dplyr (>= 0.7), +• tidyr, +• data.table, • gdata, -• stringr -• rlang -• zoo -• sdcHierarchies -• igraph +• stringr, +• rlang, +• zoo, +• sdcHierarchies, +• igraph, • lifecycle ``` @@ -202,7 +202,8 @@ rtauargus( safety_rules = "FREQ(3,10)", suppress = "GH(1,100)" ) -#> Error in rtauargus(microdata = donnees, explanatory_vars = "V1", safety_rules = "FREQ(3,10)", : impossible de trouver la fonction "rtauargus" +#> Error in `rtauargus()`: +#> ! impossible de trouver la fonction "rtauargus" ``` Comme aucune variable de réponse n'est renseignée, un comptage est effectué @@ -233,10 +234,8 @@ secret1 <- output_options = c("", "AS+"), # pas de statut pour le 1er tableau show_batch_console = FALSE # pour masquer le journal ) -#> Error in rtauargus(microdata = donnees, explanatory_vars = list("V1", : impossible de trouver la fonction "rtauargus" -``` - -``` r +#> Error in `rtauargus()`: +#> ! impossible de trouver la fonction "rtauargus" secret1 #> NULL @@ -274,7 +273,7 @@ caractéristiques. On voudrait par exemple ne générer que les fichiers asc et rda, puis lancer plusieurs batch utilisant ces mêmes fichiers. Ce n'était pas le cas dans les exemples vus jusqu'à maintenant, où tous les fichiers intermédiaires étaient -systématiquement regénérés, même si leur contenu était identique. +systématiquement régénérés, même si leur contenu était identique. Pour cela, on peut utiliser les fonctions appelées successivement par la fonction `rtauargus`, à savoir : @@ -357,6 +356,7 @@ micro_asc_rda( totcode = c("Ensemble", V2 = "TOTAL"), decimals = 1 ) + ``` Contenu des fichiers créés : @@ -398,10 +398,10 @@ dans un dossier temporaire. Il est possible de récupérer l'emplacement et le n noms_asc_rda <- micro_asc_rda(donnees) noms_asc_rda #> $asc_filename -#> [1] "C:\\Users\\KQCFFL\\AppData\\Local\\Temp\\Rtmpm05wlj\\RTA_13aa860265f1f.asc" +#> [1] "C:\\Users\\YR4UKQ\\AppData\\Local\\Temp\\RtmpKSzpVY\\RTA_110e859d6578f.asc" #> #> $rda_filename -#> [1] "C:\\Users\\KQCFFL\\AppData\\Local\\Temp\\Rtmpm05wlj\\RTA_13aa860265f1f.rda" +#> [1] "C:\\Users\\YR4UKQ\\AppData\\Local\\Temp\\RtmpKSzpVY\\RTA_110e859d6578f.rda" ```

@@ -448,7 +448,7 @@ file.show("Z:/donnees.arb", pager = "internal") ``` // Batch generated by package *rtauargus* -// (2025-02-17 12:15:37 CET) +// (2026-10-27 15:43:00 CET) "Z:\donnees.asc" "Z:\donnees.rda" "V1"|""|| @@ -494,7 +494,7 @@ file.show("Z:/donnees.arb", pager = "internal") ``` // Batch generated by package *rtauargus* -// (2025-02-17 12:15:37 CET) +// (2026-10-27 15:43:01 CET) "Z:\donnees.asc" "Z:\donnees.rda" "V1"|"VAL"|| @@ -503,9 +503,9 @@ file.show("Z:/donnees.arb", pager = "internal") FREQ(3,10)|NK(1,85) GH(1,100) - (1,4,AS+SE+,"C:\Users\KQCFFL\AppData\Local\Temp\Rtmpm05wlj\RTA_13aa84f670af.sbs") + (1,4,AS+SE+,"C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e85ac86a31.sbs") GH(2,100) - (2,4,AS+SE+,"C:\Users\KQCFFL\AppData\Local\Temp\Rtmpm05wlj\RTA_13aa836d5f26.sbs") + (2,4,AS+SE+,"C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e87e4a6f77.sbs") ``` #### Fichiers temporaires @@ -527,11 +527,11 @@ infos_arb <- ) infos_arb #> $arb_filename -#> [1] "C:\\Users\\KQCFFL\\AppData\\Local\\Temp\\Rtmpm05wlj\\RTA_13aa810e14665.arb" +#> [1] "C:\\Users\\YR4UKQ\\AppData\\Local\\Temp\\RtmpKSzpVY\\RTA_110e879151868.arb" #> #> $output_names -#> [1] "C:\\Users\\KQCFFL\\AppData\\Local\\Temp\\Rtmpm05wlj\\RTA_13aa83f037ada.sbs" -#> [2] "C:\\Users\\KQCFFL\\AppData\\Local\\Temp\\Rtmpm05wlj\\RTA_13aa842b273bd.sbs" +#> [1] "C:\\Users\\YR4UKQ\\AppData\\Local\\Temp\\RtmpKSzpVY\\RTA_110e87f305582.sbs" +#> [2] "C:\\Users\\YR4UKQ\\AppData\\Local\\Temp\\RtmpKSzpVY\\RTA_110e867bb11f7.sbs" ```

@@ -569,22 +569,19 @@ secret2 <- run_arb("Z:/donnees.arb") #> Number of suppressions: 1 #> The hypercube procedure has been applied #> 1 cells have been suppressed -#> (1,4,AS+SE+,"C:\Users\KQCFFL\AppData\Local\Temp\Rtmpm05wlj\RTA_13aa84f670af.sbs") +#> (1,4,AS+SE+,"C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e85ac86a31.sbs") #> Table: V1 | VAL has been written -#> Output file name: C:\Users\KQCFFL\AppData\Local\Temp\Rtmpm05wlj\RTA_13aa84f670af.sbs +#> Output file name: C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e85ac86a31.sbs #> GH(2,100) #> Start of the hypercube protection for table V2 x V3 | VAL #> End of hypercube protection. Time used 1 seconds #> Number of suppressions: 2 #> The hypercube procedure has been applied #> 2 cells have been suppressed -#> (2,4,AS+SE+,"C:\Users\KQCFFL\AppData\Local\Temp\Rtmpm05wlj\RTA_13aa836d5f26.sbs") +#> (2,4,AS+SE+,"C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e87e4a6f77.sbs") #> Table: V2 x V3 | VAL has been written -#> Output file name: C:\Users\KQCFFL\AppData\Local\Temp\Rtmpm05wlj\RTA_13aa836d5f26.sbs +#> Output file name: C:\Users\YR4UKQ\AppData\Local\Temp\RtmpKSzpVY\RTA_110e87e4a6f77.sbs #> End of TauArgus run -``` - -``` r secret2 #> NULL @@ -869,7 +866,7 @@ perdurera plus ou moins longtemps : à un utilisateur de garder en mémoire ses préréglages d'une session sur l'autre. -_Le deuxième façon de procéder est **à déconseiller si la chaîne de +_La deuxième façon de procéder est **déconseillée si la chaîne de traitement se veut reproductible**. En effet, un script identique exécuté sur deux machines différentes pourrait produire deux résultats différents._ @@ -919,10 +916,10 @@ Pour tout retour ou signalement d'erreur, utiliser de préférence #### À propos de cette vignette - Auteur : **Pierre-Yves Berrard** -- Dernière mise à jour : **17/02/2025** -- Version de rtauargus utilisée : **1.2.999** +- Dernière mise à jour : **27/10/2026** +- Version de rtauargus utilisée : **1.3.6** - Version de τ-Argus utilisée : **TauArgus 4.2.3** -- Version de R utilisée : **4.3.3** +- Version de R utilisée : **4.5.3**

sommaire ↑ diff --git a/vignettes/rtauargus_micro_fr.Rmd.orig b/vignettes/rtauargus_micro_fr.Rmd.orig index 66bfad9..df50a2c 100644 --- a/vignettes/rtauargus_micro_fr.Rmd.orig +++ b/vignettes/rtauargus_micro_fr.Rmd.orig @@ -251,7 +251,7 @@ caractéristiques. On voudrait par exemple ne générer que les fichiers asc et rda, puis lancer plusieurs batch utilisant ces mêmes fichiers. Ce n'était pas le cas dans les exemples vus jusqu'à maintenant, où tous les fichiers intermédiaires étaient -systématiquement regénérés, même si leur contenu était identique. +systématiquement régénérés, même si leur contenu était identique. Pour cela, on peut utiliser les fonctions appelées successivement par la fonction `rtauargus`, à savoir : @@ -634,7 +634,7 @@ perdurera plus ou moins longtemps : à un utilisateur de garder en mémoire ses préréglages d'une session sur l'autre. -_Le deuxième façon de procéder est **à déconseiller si la chaîne de +_La deuxième façon de procéder est **déconseillée si la chaîne de traitement se veut reproductible**. En effet, un script identique exécuté sur deux machines différentes pourrait produire deux résultats différents._ diff --git a/vignettes/split_tab_fr.Rmd b/vignettes/split_tab_fr.Rmd index 0dd431b..9c09f27 100644 --- a/vignettes/split_tab_fr.Rmd +++ b/vignettes/split_tab_fr.Rmd @@ -1,430 +1,433 @@ ---- -title: "Comment poser du secret sur des tableaux à 4 ou 5 dimensions avec `rtauargus`?" -subtitle:

![logo rtauargus](../man/figures/rtauargus_logo_small.png)

-output: - rmarkdown::html_vignette: - toc: true - toc_depth: 2 - number_section: true - fig_caption: true -vignette: > - %\VignetteIndexEntry{Gestion des tableaux à 4 ou 5 dimensions} - %\VignetteEngine{knitr::rmarkdown} - %\VignetteEncoding{UTF-8} ---- - - - - - -Les algorithmes de pose du secret secondaire tels qu'Optimal ou Modular implémentés -dans `Tau-Argus` reposent sur un programme d'optimisation sous contraintes. Le -nombre de ces constraintes devient très difficile à gérer - du moins dans un temps -raisonnable - pour `Tau-Argus`. La pose du secret -sur un tableau à 5 dimensions directement avec `Tau-Argus` est impossible et les résultats -fournis par le logiciel lors du traitement d'un tableau de 4 dimensions sont -accompagnés d'un avertissement. Par ailleurs, un tableau à 4 dimensions dont l'une -est hiérarchique est un problème, en général, très difficile pour `Tau-Argus`. - -Le package `rtauargus` offre désormais la possibilité de protéger des tableaux -de 4 à 5 dimensions. Pour les tableaux de 4 dimensions, la protection est -même plus rapide et permet de traiter des tableaux plus grands encore (en nombre -de lignes). Certains tableaux demeurent néanmoins trop complexes pour `Tau-Argus`. - -Cette nouvelle fonctionnalité est mise à disposition dans les fonctions -`tab_rtauargus` et `tab_multi_manager` avec l'argument `split_tab`. -Quand il est renseigné à `TRUE`, les fonctions réduisent -la dimension d'un tableau de 4 ou 5 dimensions en construisant un certain nombre -de tableaux liés de 3 dimensions chacun. Ces tableaux contiennent exactement les -mêmes cellules que le tableau original. Puis, la fonction `tab_multi_manager` est -appelée pour organiser la pose du secret sur l'ensemble de ces tableaux. -`A la fin du processus, on récupère la table de départ - avec ses dimensions -originales - augmentée des informations sur le secret secondaire. - -Ainsi, point important à retenir, la pose du secret secondaire est toujours -réalisée par les algorithmes de `Tau-Argus`, le package `rtauargus` ne fait que -découper le tableau en sous-tableaux à trois dimensions et assurer la cohérence -du secret entre ces différents sous-tableaux liés entre eux. - -Cette méthode est susceptible de générer plus de secret qu'une attaque directe -du problème. Mais celle-ci étant impossible dans les cas visés, c'est un moindre mal. - -Pour utiliser cette fonctionnalité, il est nécessaire que l'utilisateur -pose de lui-même le secret primaire en amont. - - -### Comment la réduction d'un tableau à 4 ou 5 dimensions est-elle réalisée ? - -Pour passer de 5 à 3 dimensions, on utilise deux fois de suite la méthode -utilisée pour réduire un tableau en sous-tableaux ayant une dimension de moins. - -Le passage de 4 à 3 dimensions consiste d'abord à fusionner deux des quatre -dimensions du tableau original, c'est-à-dire qu'on remplace deux des variables -de départ par une seule dont les modalités sont la fusion des modalités des -deux variables choisies. - -Dans l'exemple ci-dessous, on fusionne par exemple les deux variables `SEX` et -`AGE` pour n'en faire qu'une seule appelée `SEX_AGE`. - -
-base_tab -
- -Mais, la nouvelle variable contient des modalités non-emboîtées entre elles, -comme, par exemple, les modalités `Femme_Total` et `Ensemble_Adulte`. - -
- Total_Ensemble = Total_Adulte + Total_Enfant -
- -
- Total_Ensemble = Femme_Ensemble + Homme_Ensemble -
- -Or, nous savons gérer la présence de hiérarchies non-emboîtées dans un tableau. -Il suffit, en effet, de construire les sous-tableaux de même structure de telle -sorte que dans chacun de ces sous-tableaux la variable incriminée soit -restreinte à une partie parfaitement emboîtée de ses modalités. -Pour poser le secret sur les sous-tableaux liés engendrés, il est fait appel -à la fonction `tab_multi_manager`, spécialement conçue pour assurer la cohérence -du secret entre tableaux liés. - -Ici, la fusion nécessite la construction de deux sous-tableaux, chacun ayant une -variable `SEX__AGE` parfaitement hiérarchique. Le premier rassemble les modalités -`Total_Ensemble`, `Total_Adulte` et `Total_Enfant`, le second -`Total_Ensemble`, `Femme_Ensemble` et `Homme_Ensemble`. - -Cet exemple est le plus simple qu'il soit: en fusionnant deux variables -non hiérarchiques, on est amené à générer deux sous-tableaux. - -Lorsque l'une des variables fusionnées est elle-même hiérarchique, -la construction des sous-tableaux s'appuie sur les différents sous-totaux -présents dans la hiérarchie, comme indiqué dans la figure ci-dessous: - -
- hierarchie -
- -### Pour aller plus loin - -- [Article présentant la méthode et des résultats de simulation](https://github.com/InseeFrLab/dims_reduction_tables_workshop_20231215) - - -### Les principaux arguments ajoutés à `tab_rtauargus()` et `tab_multi_manager()` - -Pour activer le découpage des tableaux de dimension 4 ou 5 en sous-tableaux -de 3 dimensions, l'utilisateur doit activer l'argument `split_tab` en le passant -à `TRUE`. Cette valeur est sa valeur par défaut. Ainsi, l'utilisateur veillera -à passer cet argument à `FALSE` s'il souhaite qu'un tableau à 4 dimensions soit -traité directement par `Tau-Argus`. - -L'argument `nb_tab_option` permet de préciser la façon dont le tableau est découpé: - -- L'option `"min"` consiste à construire le minimum de tables à 3 dimensions -lors de la fusion. Ce sont donc des variables non hiérarchiques qui seront -fusionnées en priorité. -- L'option `"max"` au contraire construit le maximum de tables à 3 dimensions possible -lors de la fusion. Ce sont donc des variables hiérarchiques qui seront -fusionnées en priorité. Cette option est intéressante pour réduire la taille -des sous-tableaux produits et donc augmenter les chances que `Tau-Argus` puisse -les traiter. L'inconvénient de cette option est qu'elle peut générer un très -grand nombre de tableaux, nombre dépendant du nombre de noeuds dans les hiérarchies. -- L'option `"smart"` va chercher à construire le minimum de tables à 3 dimensions -tout en cherchant à respecter une limite de taille (nombre de lignes) pour les -sous-tableaux construits. Cette limite est fixée par l'argument `limit`. Par -défaut, la valeur est fixée à `14 700` - choisie de par notre expérience. Si -la limite n'est pas atteignable, un avertissement est affiché mais cela ne bloque -pas la construction des tables et la pose du masque. - -Par défaut, l'argument `nb_tab_option` est fixé à `"smart"`. Il est déconseillé -de changer cette valeur dans un premier temps. - -- L'argument `nb_tab = "min"` est intéressant en termes de secret car c'est -l'option qui génèrera le moins de sur-secret puisqu'elle construira le moins -possible de sous-tableaux liés. Il peut être intéressant à utiliser si la table -de départ contient un nombre de lignes raisonnables, -c'est-à-dire si chaque dimension n'est pas trop ventilée. -- L'argument `nb_tab = "max"` créant le plus de tableaux possibles engendrera -nécessairement le plus de secret, mais elle pourra aussi convenir quand les -tableaux d'origine sont très longs et nécessitent d'être beaucoup découpés pour -que la pose du secret soit possible avec `Tau-Argus`. - -### Exemple - -Comme tout est géré par la fonction `tab_rtauargus`, la pose du secret sur un tableau -à 4 ou 5 dimensions n'ajoute pas de difficultés particulières pour l'utilisateur -en réalité. - -Nous présentons ici un exemple de pose de secret sur un tableau à 4 dimensions. - -#### Préparation des données - - -```r -library(tictoc) -library(dplyr) -library(rtauargus) -``` - - -```r -options( - rtauargus.tauargus_exe = - "Y:/Logiciels/TauArgus/TauArgus4.2.3/TauArgus.exe" -) -``` - - - -```r -data("datatest1") -str(datatest1) -#> tibble [689 x 12] (S3: tbl_df/tbl/data.frame) -#> $ treff : chr [1:689] "tr1" "tr2" "tr3" "Total" ... -#> $ cj : chr [1:689] "Total" "Total" "Total" "PA" ... -#> $ type_distrib : chr [1:689] "Total" "Total" "Total" "Total" ... -#> $ A10 : chr [1:689] "Total" "Total" "Total" "Total" ... -#> $ nb_obs : num [1:689] 227093 7803 227 1443 125904 ... -#> $ pizzas_tot : num [1:689] 5900938 6538420 6794859 15128 10168928 ... -#> $ pizzas_max : num [1:689] 135444 267177 852749 2756 523505 ... -#> $ is_secret_freq: logi [1:689] FALSE FALSE FALSE FALSE FALSE FALSE ... -#> $ is_secret_dom : logi [1:689] FALSE FALSE FALSE FALSE FALSE FALSE ... -#> $ is_secret_prim: logi [1:689] FALSE FALSE FALSE FALSE FALSE FALSE ... -#> $ nb_obs_rnd : num [1:689] 227094 7804 228 1444 125905 ... -#> $ pizzas_tot_abs: num [1:689] 5900938 6538420 6794859 15128 10168928 ... -#> - attr(*, ".internal.selfref")= -``` - - -#### Préparation des arguments pour `tab_rtauargus` - - -```r - -totcode <- c(treff ="Total",cj ="Total", A10 = "Total", type_distrib ="Total") -explanatory_vars<- names(totcode) -``` - -#### Pose du secret primaire - - -```r -datatest1_with_prim <- datatest1 %>% - mutate( - is_secret_freq = (nb_obs > 0 & nb_obs < 3), - is_secret_dom = (pizzas_tot != 0) & (pizzas_max > 0.85*pizzas_tot), - pizzas_tot= round(abs(pizzas_tot),2) - ) %>% - mutate( - is_secret_prim = is_secret_freq , - nb_obs = ceiling(nb_obs) - ) -``` - -#### Pose du secret secondaire avec `rtauargus` - -Pour poser le secret secondaire, on utilise la fonction `tab_rtauargus` avec -l'argument `split_tab = TRUE`. Ainsi, `Tau-Argus` n'aura pas à traiter directement -le secret sur la table à 4 dimensions. La fonction `tab_rtauargus` va -découper la table originale en un certain nombre de tables qui seront protégées -comme des tables liées avec un appel sous-jacent à `tab_multi_manager`. - - - -```r -tictoc::tic() -res_wi_split <- tab_rtauargus( - tabular = datatest1_with_prim, - files_name = "datatest1", - dir_name = "example_1", - explanatory_vars = explanatory_vars, - totcode = totcode, - value = "pizzas_tot", - freq = "nb_obs", - secret_var = "is_secret_prim", - verbose = TRUE, - split_tab = TRUE -) -#> -#> Reducing dims... -#> tab -#> -#> Choosing variables... -#> -#> Reducing from 4 to 3... -#> tab has generated 2 tables in total -#> -#> Spliting... -#> treff___cj -#> tab has generated 2 tables in total -#> -#> --- Current table to treat: tab1 --- -#> --- Current table to treat: tab2 --- -#> --- Current table to treat: tab1 --- -#> --- Current table to treat: tab2 --- -#> --- Current table to treat: tab1 --- -tictoc::toc() -#> 45.31 sec elapsed -``` - -La réduction de dimensions a conduit à construire deux sous-tableaux de 3 -dimensions à partir du tableau original. - - -```r -str(res_wi_split) -#> 'data.frame': 689 obs. of 17 variables: -#> $ treff : chr "Total" "tr1" "tr1" "tr1" ... -#> $ cj : chr "Total" "LL" "SP" "Total" ... -#> $ type_distrib : chr "1" "1" "1" "1" ... -#> $ A10 : chr "AZ" "AZ" "AZ" "AZ" ... -#> $ nb_obs : num 115 89 21 110 6 ... -#> $ pizzas_tot : num 8447 769 1301 532 7915 ... -#> $ pizzas_max : num 1471.2 13.8 96.4 96.4 1471.2 ... -#> $ is_secret_freq: logi FALSE FALSE FALSE FALSE FALSE FALSE ... -#> $ is_secret_dom : logi FALSE TRUE FALSE FALSE FALSE FALSE ... -#> $ is_secret_prim: logi FALSE FALSE FALSE FALSE FALSE FALSE ... -#> $ nb_obs_rnd : num 115 89 21 110 6 ... -#> $ pizzas_tot_abs: num 8447 769 1301 532 7915 ... -#> $ is_secret_1 : logi FALSE TRUE FALSE TRUE TRUE TRUE ... -#> $ is_secret_2 : logi FALSE TRUE TRUE TRUE TRUE TRUE ... -#> $ is_secret_3 : logi FALSE TRUE TRUE TRUE TRUE TRUE ... -#> $ is_secret_4 : logi FALSE TRUE TRUE TRUE TRUE TRUE ... -#> $ is_secret_5 : logi FALSE TRUE TRUE TRUE TRUE TRUE ... -``` - - -```r -stats_wi_split <- res_wi_split %>% - rename_with( ~"final_suppress", last_col()) %>% - mutate( - flag = case_when( - is_secret_freq ~ "A", - is_secret_dom ~ "B", - final_suppress ~ "D", - TRUE ~"V" - ) - ) %>% - count(flag) -stats_wi_split -#> flag n -#> 1 A 79 -#> 2 B 35 -#> 3 D 278 -#> 4 V 297 -``` - -Avec l'option de découpage du tableau de départ, la pose du secret sur -le tableau à 4 dimensions génère -278 suppressions secondaires. - -#### Comparaison avec une pose du secret sans réduire la dimension de la table - -`Tau-Argus` est en capacité de poser le secret secondaire sur un tableau à 4 -dimensions avec `Modular`, mais, en plus d'émettre un avertissement sur le -fait qu'avec ce nombre de dimensions, la qualité du résultat n'est pas garantie, -il est aussi beaucoup plus long à poser le secret secondaire que lorsqu'il -traite deux tables liées issues du tableau original. - - -```r -tictoc::tic() -res_wo_split <- tab_rtauargus( - tabular = datatest1_with_prim, - files_name = "datatest1", - dir_name = "example_1/wo_split", - explanatory_vars = explanatory_vars, - totcode = totcode, - value = "pizzas_tot", - freq = "nb_obs", - secret_var = "is_secret_prim", - verbose = TRUE, - split_tab = FALSE -) -#> Warning : -#> It is highly recommended to use split_tab = TRUE when using rtauargus with 4 or 5 dimensions tables. -#> It allows to split the table in several tables with 3 dimensions. -#> -#> With split_tab = FALSE, tauargus treats the table in 4 or 5 dimensions. -#> In this case, the secondary secret may not being optimal according to tauargus itself -#> and the process may take longer. -#> Start of batch procedure; file: Z:\SDC\OutilsConfidentialite\rtauargus\vignettes\example_1\wo_split\datatest1.arb -#> "Z:\SDC\OutilsConfidentialite\rtauargus\vignettes\example_1\wo_split\datatest1.tab" -#> "Z:\SDC\OutilsConfidentialite\rtauargus\vignettes\example_1\wo_split\datatest1.rda" -#> "treff""cj""A10""type_distrib"|"pizzas_tot"|| -#> MAN(10) -#> 1 -#> Tables have been read -#> "Z:\SDC\OutilsConfidentialite\rtauargus\vignettes\example_1\wo_split\datatest1.hst",1,",",0,0 -#> Apriory file: Z:\SDC\OutilsConfidentialite\rtauargus\vignettes\example_1\wo_split\datatest1.hst has been applied -#> to table: treff x cj x A10 x type_distrib | pizzas_tot -#> Apriori file Z:\SDC\OutilsConfidentialite\rtauargus\vignettes\example_1\wo_split\datatest1.hst has been read -#> MOD(1,5,1,0,0) -#> Start of the modular protection for table treff x cj x A10 x type_distrib | pizzas_tot -#> WARNING: The table has 4 dimensions. -#> Running Modular can take a lot of time and maybe it is difficult to obtain a correct result. -#> Please check the results carefully. -#> -#> End of modular protection. Time used 301 seconds -#> Number of suppressions: 291 -#> (1,4,,"Z:\SDC\OutilsConfidentialite\rtauargus\vignettes\example_1\wo_split\datatest1.csv") -#> Table: treff x cj x A10 x type_distrib | pizzas_tot has been written -#> Output file name: Z:\SDC\OutilsConfidentialite\rtauargus\vignettes\example_1\wo_split\datatest1.csv -#> End of TauArgus run -tictoc::toc() -#> 306.34 sec elapsed -``` - -Avec seulement 689 lignes et aucune variable hiérarchique, la pose directe du -secret prend environ 5 minutes à `Tau-Argus`. - - -```r -stats_wo_split <- res_wo_split %>% - mutate( - flag = case_when( - is_secret_freq ~ "A", - is_secret_dom ~ "B", - TRUE ~ Status - ) - ) %>% - count(flag) -stats_wo_split -#> flag n -#> 1 A 79 -#> 2 B 35 -#> 3 D 265 -#> 4 V 310 -``` - -La pose directe du secret sur le tableau à 4 dimensions génère -265 suppressions secondaires. - - -On peut observer que le traitement de la table à 4 dimensions directement -génère un masque un peu moins chargé en secret: 266 cellules en secret secondaire, -contre 278 avec une réduction de dimensions. - -Il est difficile d'anticiper cette différence puisqu'elle est très dépendante -de la structuration des données, de la présence du secret primaire au sein du -tableau original et de la façon dont les sous-tableaux vont être construits. - - -## Détail de la vignette - -- Authors: ** Wistan Pomel ** & ** Andre-Raymond Socard ** & -**Julien Jamme** & -**Nathanael Rastout** -- Last update: **11/01/2024** -- Version of rtauargus used: **1.2.0** -- Version of τ-Argus used : **TauArgus 4.2.3** -- R version used : **4.2.3** - -

- summary ↑ -

- +--- +title: "Comment poser du secret sur des tableaux à 4 ou 5 dimensions avec `rtauargus`?" +subtitle:

![logo rtauargus](../man/figures/rtauargus_logo_small.png)

+output: + rmarkdown::html_vignette: + toc: true + toc_depth: 2 + number_section: true + fig_caption: true +vignette: > + %\VignetteIndexEntry{Gestion des tableaux à 4 ou 5 dimensions} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + + + + + +Les algorithmes de pose du secret secondaire tels qu'Optimal ou Modular implémentés +dans `Tau-Argus` reposent sur un programme d'optimisation sous contraintes. Le +nombre de ces constraintes devient très difficile à gérer - du moins dans un temps +raisonnable - pour `Tau-Argus`. La pose du secret +sur un tableau à 5 dimensions directement avec `Tau-Argus` est impossible et les résultats +fournis par le logiciel lors du traitement d'un tableau de 4 dimensions sont +accompagnés d'un avertissement. Par ailleurs, un tableau à 4 dimensions dont l'une +est hiérarchique est un problème, en général, très difficile pour `Tau-Argus`. + +Le package `rtauargus` offre désormais la possibilité de protéger des tableaux +de 4 à 5 dimensions. Pour les tableaux de 4 dimensions, la protection est +même plus rapide et permet de traiter des tableaux plus grands encore (en nombre +de lignes). Certains tableaux demeurent néanmoins trop complexes pour `Tau-Argus`. + +Cette nouvelle fonctionnalité est mise à disposition dans les fonctions +`tab_rtauargus` et `tab_multi_manager` avec l'argument `split_tab`. +Quand il est renseigné à `TRUE`, les fonctions réduisent +la dimension d'un tableau de 4 ou 5 dimensions en construisant un certain nombre +de tableaux liés de 3 dimensions chacun. Ces tableaux contiennent exactement les +mêmes cellules que le tableau original. Puis, la fonction `tab_multi_manager` est +appelée pour organiser la pose du secret sur l'ensemble de ces tableaux. +`A la fin du processus, on récupère la table de départ - avec ses dimensions +originales - augmentée des informations sur le secret secondaire. + +Ainsi, point important à retenir, la pose du secret secondaire est toujours +réalisée par les algorithmes de `Tau-Argus`, le package `rtauargus` ne fait que +découper le tableau en sous-tableaux à trois dimensions et assurer la cohérence +du secret entre ces différents sous-tableaux liés entre eux. + +Cette méthode est susceptible de générer plus de secret qu'une attaque directe +du problème. Mais celle-ci étant impossible dans les cas visés, c'est un moindre mal. + +Pour utiliser cette fonctionnalité, il est nécessaire que l'utilisateur +pose de lui-même le secret primaire en amont. + + +### Comment la réduction d'un tableau à 4 ou 5 dimensions est-elle réalisée ? + +Pour passer de 5 à 3 dimensions, on utilise deux fois de suite la méthode +utilisée pour réduire un tableau en sous-tableaux ayant une dimension de moins. + +Le passage de 4 à 3 dimensions consiste d'abord à fusionner deux des quatre +dimensions du tableau original, c'est-à-dire qu'on remplace deux des variables +de départ par une seule dont les modalités sont la fusion des modalités des +deux variables choisies. + +Dans l'exemple ci-dessous, on fusionne par exemple les deux variables `SEX` et +`AGE` pour n'en faire qu'une seule appelée `SEX_AGE`. + +
+base_tab +
+ +Mais, la nouvelle variable contient des modalités non-emboîtées entre elles, +comme, par exemple, les modalités `Femme_Total` et `Ensemble_Adulte`. + +
+ Total_Ensemble = Total_Adulte + Total_Enfant +
+ +
+ Total_Ensemble = Femme_Ensemble + Homme_Ensemble +
+ +Or, nous savons gérer la présence de hiérarchies non-emboîtées dans un tableau. +Il suffit, en effet, de construire les sous-tableaux de même structure de telle +sorte que dans chacun de ces sous-tableaux la variable incriminée soit +restreinte à une partie parfaitement emboîtée de ses modalités. +Pour poser le secret sur les sous-tableaux liés engendrés, il est fait appel +à la fonction `tab_multi_manager`, spécialement conçue pour assurer la cohérence +du secret entre tableaux liés. + +Ici, la fusion nécessite la construction de deux sous-tableaux, chacun ayant une +variable `SEX__AGE` parfaitement hiérarchique. Le premier rassemble les modalités +`Total_Ensemble`, `Total_Adulte` et `Total_Enfant`, le second +`Total_Ensemble`, `Femme_Ensemble` et `Homme_Ensemble`. + +Cet exemple est le plus simple qu'il soit: en fusionnant deux variables +non hiérarchiques, on est amené à générer deux sous-tableaux. + +Lorsque l'une des variables fusionnées est elle-même hiérarchique, +la construction des sous-tableaux s'appuie sur les différents sous-totaux +présents dans la hiérarchie, comme indiqué dans la figure ci-dessous: + +
+ hierarchie +
+ +### Pour aller plus loin + +- [Article présentant la méthode et des résultats de simulation](https://github.com/InseeFrLab/dims_reduction_tables_workshop_20231215) + + +### Les principaux arguments ajoutés à `tab_rtauargus()` et `tab_multi_manager()` + +Pour activer le découpage des tableaux de dimension 4 ou 5 en sous-tableaux +de 3 dimensions, l'utilisateur doit activer l'argument `split_tab` en le passant +à `TRUE`. Cette valeur est sa valeur par défaut. Ainsi, l'utilisateur veillera +à passer cet argument à `FALSE` s'il souhaite qu'un tableau à 4 dimensions soit +traité directement par `Tau-Argus`. + +L'argument `nb_tab_option` permet de préciser la façon dont le tableau est découpé: + +- L'option `"min"` consiste à construire le minimum de tables à 3 dimensions +lors de la fusion. Ce sont donc des variables non hiérarchiques qui seront +fusionnées en priorité. +- L'option `"max"` au contraire construit le maximum de tables à 3 dimensions possible +lors de la fusion. Ce sont donc des variables hiérarchiques qui seront +fusionnées en priorité. Cette option est intéressante pour réduire la taille +des sous-tableaux produits et donc augmenter les chances que `Tau-Argus` puisse +les traiter. L'inconvénient de cette option est qu'elle peut générer un très +grand nombre de tableaux, nombre dépendant du nombre de noeuds dans les hiérarchies. +- L'option `"smart"` va chercher à construire le minimum de tables à 3 dimensions +tout en cherchant à respecter une limite de taille (nombre de lignes) pour les +sous-tableaux construits. Cette limite est fixée par l'argument `limit`. Par +défaut, la valeur est fixée à `14 700` - choisie de par notre expérience. Si +la limite n'est pas atteignable, un avertissement est affiché mais cela ne bloque +pas la construction des tables et la pose du masque. + +Par défaut, l'argument `nb_tab_option` est fixé à `"smart"`. Il est déconseillé +de changer cette valeur dans un premier temps. + +- L'argument `nb_tab = "min"` est intéressant en termes de secret car c'est +l'option qui génèrera le moins de sur-secret puisqu'elle construira le moins +possible de sous-tableaux liés. Il peut être intéressant à utiliser si la table +de départ contient un nombre de lignes raisonnables, +c'est-à-dire si chaque dimension n'est pas trop ventilée. +- L'argument `nb_tab = "max"` créant le plus de tableaux possibles engendrera +nécessairement le plus de secret, mais elle pourra aussi convenir quand les +tableaux d'origine sont très longs et nécessitent d'être beaucoup découpés pour +que la pose du secret soit possible avec `Tau-Argus`. + +### Exemple + +Comme tout est géré par la fonction `tab_rtauargus`, la pose du secret sur un tableau +à 4 ou 5 dimensions n'ajoute pas de difficultés particulières pour l'utilisateur +en réalité. + +Nous présentons ici un exemple de pose de secret sur un tableau à 4 dimensions. + +#### Préparation des données + + +``` r +library(tictoc) +#> +#> Attachement du package : 'tictoc' +#> L'objet suivant est masqué depuis 'package:rtauargus': +#> +#> shift +library(dplyr) +library(rtauargus) +``` + + +``` r +options( + rtauargus.tauargus_exe = + "Y:/Logiciels/TauArgus/TauArgus4.2.3/TauArgus.exe" +) +``` + + + +``` r +data("datatest1") +str(datatest1) +#> tibble [689 x 12] (S3: tbl_df/tbl/data.frame) +#> $ treff : chr [1:689] "tr1" "tr2" "tr3" "Total" ... +#> $ cj : chr [1:689] "Total" "Total" "Total" "PA" ... +#> $ type_distrib : chr [1:689] "Total" "Total" "Total" "Total" ... +#> $ A10 : chr [1:689] "Total" "Total" "Total" "Total" ... +#> $ nb_obs : num [1:689] 227093 7803 227 1443 125904 ... +#> $ pizzas_tot : num [1:689] 5900938 6538420 6794859 15128 10168928 ... +#> $ pizzas_max : num [1:689] 135444 267177 852749 2756 523505 ... +#> $ is_secret_freq: logi [1:689] FALSE FALSE FALSE FALSE FALSE FALSE ... +#> $ is_secret_dom : logi [1:689] FALSE FALSE FALSE FALSE FALSE FALSE ... +#> $ is_secret_prim: logi [1:689] FALSE FALSE FALSE FALSE FALSE FALSE ... +#> $ nb_obs_rnd : num [1:689] 227094 7804 228 1444 125905 ... +#> $ pizzas_tot_abs: num [1:689] 5900938 6538420 6794859 15128 10168928 ... +#> - attr(*, ".internal.selfref")= +``` + + +#### Préparation des arguments pour `tab_rtauargus` + + +``` r + +totcode <- c(treff ="Total",cj ="Total", A10 = "Total", type_distrib ="Total") +explanatory_vars<- names(totcode) + +``` + +#### Pose du secret primaire + + +``` r +datatest1_with_prim <- datatest1 %>% + mutate( + is_secret_freq = (nb_obs > 0 & nb_obs < 3), + is_secret_dom = (pizzas_tot != 0) & (pizzas_max > 0.85*pizzas_tot), + pizzas_tot= round(abs(pizzas_tot),2) + ) %>% + mutate( + is_secret_prim = is_secret_freq , + nb_obs = ceiling(nb_obs) + ) +``` + +#### Pose du secret secondaire avec `rtauargus` + +Pour poser le secret secondaire, on utilise la fonction `tab_rtauargus` avec +l'argument `split_tab = TRUE`. Ainsi, `Tau-Argus` n'aura pas à traiter directement +le secret sur la table à 4 dimensions. La fonction `tab_rtauargus` va +découper la table originale en un certain nombre de tables qui seront protégées +comme des tables liées avec un appel sous-jacent à `tab_multi_manager`. + + + +``` r +tictoc::tic() +res_wi_split <- tab_rtauargus( + tabular = datatest1_with_prim, + files_name = "datatest1", + dir_name = "example_1", + explanatory_vars = explanatory_vars, + totcode = totcode, + value = "pizzas_tot", + freq = "nb_obs", + secret_var = "is_secret_prim", + verbose = TRUE, + split_tab = TRUE +) +#> +#> Reducing dims... +#> datatest1 +#> +#> Choosing variables... +#> +#> Reducing from 4 to 3... +#> datatest1_ has generated 2 tables in total +#> +#> Table size distribution : +#> Min. 1st Qu. Median Mean 3rd Qu. Max. +#> 535.0 536.5 538.0 538.0 539.5 541.0 +#> +#> +#> --- Current table to treat: datatest1_1 | loop iter : 1 --- --- Current table to treat: datatest1_2 | loop iter : 2 --- --- Current table to treat: datatest1_1 | loop iter : 3 --- --- Current table to treat: datatest1_2 | loop iter : 4 --- --- Current table to treat: datatest1_1 | loop iter : 5 --- +tictoc::toc() +#> 43.21 sec elapsed +``` + +La réduction de dimensions a conduit à construire deux sous-tableaux de 3 +dimensions à partir du tableau original. + + +``` r +str(res_wi_split) +#> 'data.frame': 689 obs. of 17 variables: +#> $ treff : chr "Total" "tr1" "tr1" "tr1" ... +#> $ cj : chr "Total" "LL" "SP" "Total" ... +#> $ type_distrib : chr "1" "1" "1" "1" ... +#> $ A10 : chr "AZ" "AZ" "AZ" "AZ" ... +#> $ nb_obs : num 115 89 21 110 6 ... +#> $ pizzas_tot : num 8447 769 1301 532 7915 ... +#> $ pizzas_max : num 1471.2 13.8 96.4 96.4 1471.2 ... +#> $ is_secret_freq: logi FALSE FALSE FALSE FALSE FALSE FALSE ... +#> $ is_secret_dom : logi FALSE TRUE FALSE FALSE FALSE FALSE ... +#> $ is_secret_prim: logi FALSE FALSE FALSE FALSE FALSE FALSE ... +#> $ nb_obs_rnd : num 115 89 21 110 6 ... +#> $ pizzas_tot_abs: num 8447 769 1301 532 7915 ... +#> $ is_secret_1 : logi FALSE TRUE TRUE TRUE TRUE TRUE ... +#> $ is_secret_2 : logi FALSE TRUE TRUE TRUE TRUE TRUE ... +#> $ is_secret_3 : logi FALSE TRUE TRUE TRUE TRUE TRUE ... +#> $ is_secret_4 : logi FALSE TRUE TRUE TRUE TRUE TRUE ... +#> $ is_secret_5 : logi FALSE TRUE TRUE TRUE TRUE TRUE ... +``` + + +``` r +stats_wi_split <- res_wi_split %>% + rename_with( ~"final_suppress", last_col()) %>% + mutate( + flag = case_when( + is_secret_freq ~ "A", + is_secret_dom ~ "B", + final_suppress ~ "D", + TRUE ~"V" + ) + ) %>% + count(flag) +stats_wi_split +#> flag n +#> 1 A 79 +#> 2 B 35 +#> 3 D 280 +#> 4 V 295 +``` + +Avec l'option de découpage du tableau de départ, la pose du secret sur +le tableau à 4 dimensions génère +280 suppressions secondaires. + +#### Comparaison avec une pose du secret sans réduire la dimension de la table + +`Tau-Argus` est en capacité de poser le secret secondaire sur un tableau à 4 +dimensions avec `Modular`, mais, en plus d'émettre un avertissement sur le +fait qu'avec ce nombre de dimensions, la qualité du résultat n'est pas garantie, +il est aussi beaucoup plus long à poser le secret secondaire que lorsqu'il +traite deux tables liées issues du tableau original. + + +``` r +tictoc::tic() +res_wo_split <- tab_rtauargus( + tabular = datatest1_with_prim, + files_name = "datatest1", + dir_name = "example_1/wo_split", + explanatory_vars = explanatory_vars, + totcode = totcode, + value = "pizzas_tot", + freq = "nb_obs", + secret_var = "is_secret_prim", + verbose = TRUE, + split_tab = FALSE +) +#> Warning : +#> It is highly recommended to use split_tab = TRUE when using rtauargus with 4 or 5 dimensions tables. +#> It allows to split the table in several tables with 3 dimensions. +#> +#> With split_tab = FALSE, tauargus treats the table in 4 or 5 dimensions. +#> In this case, the secondary secret may not being optimal according to tauargus itself +#> and the process may take longer. +#> Start of batch procedure; file: Z:\confidentialite\rtauargus\vignettes\example_1\wo_split\datatest1.arb +#> "Z:\confidentialite\rtauargus\vignettes\example_1\wo_split\datatest1.tab" +#> "Z:\confidentialite\rtauargus\vignettes\example_1\wo_split\datatest1.rda" +#> "treff""cj""A10""type_distrib"|"pizzas_tot"|| +#> MAN(10) +#> 1 +#> Tables have been read +#> "Z:\confidentialite\rtauargus\vignettes\example_1\wo_split\datatest1.hst",1,",",0,0 +#> Apriory file: Z:\confidentialite\rtauargus\vignettes\example_1\wo_split\datatest1.hst has been applied +#> to table: treff x cj x A10 x type_distrib | pizzas_tot +#> Apriori file Z:\confidentialite\rtauargus\vignettes\example_1\wo_split\datatest1.hst has been read +#> MOD(1,5,1,0,0) +#> Start of the modular protection for table treff x cj x A10 x type_distrib | pizzas_tot +#> WARNING: The table has 4 dimensions. +#> Running Modular can take a lot of time and maybe it is difficult to obtain a correct result. +#> Please check the results carefully. +#> +#> End of modular protection. Time used 305 seconds +#> Number of suppressions: 292 +#> (1,4,,"Z:\confidentialite\rtauargus\vignettes\example_1\wo_split\datatest1.csv") +#> Table: treff x cj x A10 x type_distrib | pizzas_tot has been written +#> Output file name: Z:\confidentialite\rtauargus\vignettes\example_1\wo_split\datatest1.csv +#> End of TauArgus run +tictoc::toc() +#> 309.53 sec elapsed +``` + +Avec seulement 689 lignes et aucune variable hiérarchique, la pose directe du +secret prend environ 5 minutes à `Tau-Argus`. + + +``` r +stats_wo_split <- res_wo_split %>% + mutate( + flag = case_when( + is_secret_freq ~ "A", + is_secret_dom ~ "B", + TRUE ~ Status + ) + ) %>% + count(flag) +stats_wo_split +#> flag n +#> 1 A 79 +#> 2 B 35 +#> 3 D 266 +#> 4 V 309 +``` + +La pose directe du secret sur le tableau à 4 dimensions génère +266 suppressions secondaires. + + +On peut observer que le traitement de la table à 4 dimensions directement +génère un masque un peu moins chargé en secret: 266 cellules en secret secondaire, +contre 278 avec une réduction de dimensions. + +Il est difficile d'anticiper cette différence puisqu'elle est très dépendante +de la structuration des données, de la présence du secret primaire au sein du +tableau original et de la façon dont les sous-tableaux vont être construits. + + +## Détail de la vignette + +- Authors: ** Wistan Pomel ** & ** Andre-Raymond Socard ** & +**Julien Jamme** & +**Nathanael Rastout** +- Last update: **27/10/2026** +- Version of rtauargus used: **1.3.6** +- Version of τ-Argus used : **TauArgus 4.2.3** +- R version used : **4.5.3** + +

+ summary ↑ +

+