diff --git a/.gitignore b/.gitignore index 13a64cb..cd82e17 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ .Rhistory .RData inst/doc -docs *.xlsx sqlnet.log /doc/ diff --git a/NAMESPACE b/NAMESPACE index c01f64f..07ec504 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -56,6 +56,7 @@ importFrom(methods,is) importFrom(openxlsx,addStyle) importFrom(openxlsx,makeHyperlinkString) importFrom(openxlsx,writeFormula) +importFrom(purrr,reduce2) importFrom(rlang,":=") importFrom(rlang,.data) importFrom(scales,manual_pal) diff --git a/R/insert_index_sheet.R b/R/insert_index_sheet.R index 2a4c228..b018599 100644 --- a/R/insert_index_sheet.R +++ b/R/insert_index_sheet.R @@ -34,7 +34,7 @@ insert_index_sheet <- function( 3:18, style_subtitle(), "source") ### Table of content caption - writeText(wb, sheetname, getOption("statR_index_title"), + writeText(wb, sheetname, getOption("statR_index_toc_title"), namedRegionLastRow(wb, sheetname, "source") + 3, 3, style_indextitle(), "toc") diff --git a/R/output_xlsx.R b/R/output_xlsx.R index eda003d..ad83f13 100644 --- a/R/output_xlsx.R +++ b/R/output_xlsx.R @@ -37,6 +37,7 @@ #' in inches (1 inch = 2.54 cm), or a list of the same length as `datasets` #' @param index_title Title to be put on the index sheet. #' @param index_source Source to be shown below the index title. +#' @param index_toc_title Title shown above the table of content. #' @param metadata_sheet A list with named elements 'title', 'source', and 'text'. #' Intended for conveying long-form information. Default is NULL, not included. #' @param overwrite Overwrites the existing excel files with the same file name. @@ -124,12 +125,12 @@ datasetsXLSX <- function( file, datasets, sheetname = NULL, title = NULL, source = NULL, metadata = NULL, grouplines = NULL, group_names = NULL, plot_width = NULL, - plot_height = NULL, index_title = NA, index_source = NA, logo = NA, - contactdetails = NA, homepage = NA, openinghours = NA, auftrag_id = NULL, + plot_height = NULL, index_title = NA, index_source = NA, index_toc_title = NA, + logo = NA, contactdetails = NA, homepage = NA, openinghours = NA, auftrag_id = NULL, author = "user", metadata_sheet = NULL, overwrite = TRUE, config = "default") { - get_user_config(config, c(index_title, index_source, logo, + get_user_config(config, c(index_title, index_source, index_toc_title, logo, contactdetails, homepage, openinghours)) # "Optional" input arguments @@ -178,7 +179,7 @@ datasetsXLSX <- function( sheetname <- verifyInputSheetnames(sheetname) wb <- openxlsx::createWorkbook() - insert_index_sheet(wb, sheetname = "Index", title = index_title, + insert_index_sheet(wb, sheetname = "Index", title = getOption("statR_index_title"), auftrag_id = auftrag_id, logo = logo, contactdetails = getOption("statR_contactdetails"), homepage = getOption("statR_homepage"), diff --git a/R/user_config.R b/R/user_config.R index e388b9a..2e25573 100644 --- a/R/user_config.R +++ b/R/user_config.R @@ -21,9 +21,7 @@ initUserConfigStore <- function(store_path = "~/.config/R/statR") { } - addUserConfig(store_path = store_path) - } @@ -47,12 +45,16 @@ addUserConfig <- function(name = "default", path = NULL, store_path = "~/.config/R/statR") { store_file <- file.path(store_path, "statR_profile.csv") + configs <- readUserConfigStore(store_path) - if(!file.exists(store_file)){ + lib_path <- dirname(dirname(system.file(package = "statR"))) + current_path <- configs[configs$config_name == name, "config_path"] + default_path <- system.file("extdata/config/default.yaml", package = "statR") + + if (!file.exists(store_file)){ initUserConfigStore(store_path) } - configs <- readUserConfigStore(store_path) if (is.null(path) && name != "default") { stop("Kein Pfad zu config file angegeben") } @@ -62,22 +64,30 @@ addUserConfig <- function(name = "default", path = NULL, } if (name == "default" && is.null(path)) { - path <- system.file("extdata/config/default.yaml", package = "statR") + + if (length(current_path) == 0) { + path <- default_path + + } else if (grepl(lib_path, current_path)) { + curr_vers <- paste0(version$major, ".", gsub(".[0-9]+$", "", version$minor)) + path <- gsub("[0-9.]+/statR/extdata/config/", + paste0(curr_vers, "/", "statR/extdata/config/"), current_path) + updateUserConfig("default", path, store_path) + } } - if (name == "default" & "default" %in% configs$config_name){ + if (name == "default" && "default" %in% configs$config_name){ return("Alles bereit") } if (name %in% configs$config_name){ - if (configs[configs$config_name == name, "config_path"] == path){ + if (current_path == path){ stop("Diese Konfiguration existiert bereits! Verwende die ", "updateUserConfig()-Funktion um den Pfad zu aendern.") } else { - stop("Der Konfigurationsname: ", - configs[configs$config_name == name, "config_name"], + stop("Der Konfigurationsname: ", name, " existiert bereits. Setze einen neuen Pfad mit der ", "updateUserConfig()-Funktion") } @@ -95,18 +105,22 @@ addUserConfig <- function(name = "default", path = NULL, #' @inheritParams initUserConfigStore #' @export updateUserConfig <- function(name, path, store_path = "~/.config/R/statR"){ - if (!is.null(path) && !file.exists(path)) { - stop("No config file found at ", path) - } configs <- readUserConfigStore(store_path) - configs[configs$config_name == name, "config_path"] <- path + if (name == "default") { + curr_vers <- paste0(version$major, ".", gsub(".[0-9]+$", "", version$minor)) + path <- gsub("[0-9.]+/statR/extdata/config/", + paste0(curr_vers, "/", "statR/extdata/config/"), path) + } - out <- configs + if (!is.null(path) && !file.exists(path)) { + stop("No config file found at ", path) + } + configs[configs$config_name == name, "config_path"] <- path store_file <- file.path(store_path, "statR_profile.csv") - write.table(out, store_file, row.names = FALSE, sep = ",") + write.table(configs, store_file, row.names = FALSE, sep = ",") } #' Loeschen eines Konfigurations-Eintrages @@ -145,39 +159,35 @@ readUserConfig <- function(name = "default", store_path = "~/.config/R/statR") { } - - - - +#' Extrahiert Defaults aus User Config und ersetzt Werte +#' @param config Name der User Config +#' @param params_to_check Vektor mit Parametern +#' @importFrom purrr reduce2 +#' @keywords internal get_user_config <- function(config, params_to_check){ initUserConfigStore() - user_config <- readUserConfig(config) - out <- unlist(user_config, recursive = FALSE) - names(out) <- gsub(".*\\.", "", names(out)) - config_name <- tail(paste0("statR_", substitute(params_to_check)), -1) - - - user_config <- purrr::reduce2(params_to_check, config_name, ~ replace_by_parameter(..1, ..2, ..3), .init = out) - + user_config <- purrr::reduce2(params_to_check, config_name, + ~ replace_by_parameter(..1, ..2, ..3), + .init = out) options(user_config) - - if(!("statR_contactdetails" %in% names(user_config))){ + if (!("statR_contactdetails" %in% names(user_config))){ user_config$statR_contactdetails <- inputHelperContactInfo() - options(user_config) } - - - } +#' Ersetzt Werte in aktiver Config mit gesetzten Parametern +#' @param yaml_file Inhalt der aktiven Config +#' @param parameter Wert des Parameters +#' @param config_param_name Name des Parameters +#' @keywords internal replace_by_parameter <- function(yaml_file, parameter, config_param_name) { if (!is.na(parameter)) { @@ -185,15 +195,9 @@ replace_by_parameter <- function(yaml_file, parameter, config_param_name) { yaml_file[config_param_name] <- parameter } else { yaml_file$add <- parameter - new_names <- c(head(names(yaml_file),-1), config_param_name) - names(yaml_file) <- new_names } - } - return(yaml_file) } - - diff --git a/docs/.nojekyll b/docs/.nojekyll new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/docs/.nojekyll @@ -0,0 +1 @@ + diff --git a/docs/404.html b/docs/404.html index c8012a1..d172469 100644 --- a/docs/404.html +++ b/docs/404.html @@ -50,6 +50,9 @@
vignettes/Benutzerkonfiguration.Rmd
+ Benutzerkonfiguration.RmdDie Benutzerkonfiguration erlaubt es, Informationen den Excel-Outputs +mitzugeben. Diese werden global gesetzt und jedes Excel-File enthält die +selben Informationen. Dies ermöglicht, Team-Spezifische oder +Organisations-Spezifische Konfigurationen zu setzten. Die +Benutzerkonfiguration lebt nicht mehr im Package direkt, sondern es wird +ein Pfad zur Konfiguration angegeben. Der Grund für diese Auslagerung +der Informationen ist, dass so ein ganzes Team auf die Gleiche +Konfiguration zugreifen kann. Falls keine eigene Konfiguration verwenet +wird, fallen die Werte auf einen Default-Wert zurück, welche im Package +hinterlegt sind.
+Die Benutzerkonfiguration wird in einem YAML-File gemacht. Sie muss +gleich sein wie das untenstehende Beispiel:
+# Configuration file for statR
+statR_config_name: default
+
+# Contact information
+contactdetails:
+ statR_organization: Statistisches Amt des Kantons Zürich
+ statR_name: Datashop
+ statR_phone: +41 43 259 75 00
+ statR_email: datashop@statistik.zh.ch
+ statR_homepage: http://www.statistik.zh.ch
+ statR_openinghours:
+ - Bürozeiten
+ - Montag bis Freitag
+ - 09:00 bis 12:00
+ - 13:00 bis 16:00
+
+# Logo: this can be one of the values statzh or zh, or a path to an image
+logo:
+ statR_logo: statzh
+ statR_logo_width: 2.145
+ statR_logo_height: 0.7865
+
+# Prefixes for strings
+prefixes:
+ statR_prefix_date: "Aktualisiert am:"
+ statR_prefix_author: "durch:"
+ statR_prefix_phone: "Tel."
+ statR_prefix_order_id: "Auftragsnr.:"
+
+# Default values
+defaults:
+ statR_index_title: Inhalt
+ statR_index_source: Statistisches Amt des Kantons Zürich
+ statR_default_plot_width: 6
+ statR_default_plot_height: 3
+
+# Miscellaneous
+statR_date_format: "%d.%m.%Y"Du hast die folgenden Konfigurations-Möglichkeiten:
+contactdetails
+In diesem Bereich kannst du die Kontakt-Informationen deines Teams +oder der Organisation angeben.
+logo
+Hier kannst du die Angaben zum Logo machen, welches in den +Excel-Files angezeigt werden soll. Wenn du nicht das standard KTZH-Logo +verwenden möchtest, musst du einen Pfad zu einem anderen Logo +angeben.
+prefixes
+Hier kannst du bestimmte Schreibweisen definieren. Dieser Teil ist +vor allem dafür gedacht, dass eine andere Sprache konfiguriert werden +kann.
+defaults
+Hier können bestimmte Default Settings gesetzt werden. Unter anderem +kannst du hier für das Index-Scheet (relevant bei datasets.xlsx) einen +Titel sowie die Source definieren. Zudem kannst du hier default +Plot-Grössen definieren. Diese Angaben könnten in den Funktionen auch +überschrieben werden, wenn ein Plot dem Standard abweicht.
+Eine eigene Benutzerkonfiguration wird nicht automatisch im Package +verwendet. Wir müssem dem Package zuerst sagen, wo unsere Konfiguration +liegt.
+Dazu gibt es ein paar Hilfsfunktionen:
+Mit addUserConfig() kann eine neuer Konfiguration
+registriert werden.
Mit updateUserConfig() kann ein Pfad angepasst
+werden.
Mit removeUserConfig() kann eine Konfiguration
+entfernt werden.
Wenn du nun zum Beispiel eine Team-Konfiguration verwenden möchtest, +dann kannst du wie folgt vorgehen:
+Kopiere die oben aufgeführten Angaben und passe sie für dich +an
Speichere das File als YAML ab (.yaml)
registriere das neue Konfigurationsfile (hier als Beispiel für +team_data):
+addUserConfig(name = "team_data", path = "der_Pfad_zum_file")
wenn du eine Exce-Funktion aufrufst, setze den Parameter
+config = "team_data"
Du hast auch die möglichkeit mehrere Konfigurationen zu registrieren.
+Du kannst dann einfach mit dem config-Parameter bestimmen,
+welche Konfiguration angezogen werden soll.
Wichtig! Auch noch den Artikel der Benutzerkonfiguration lesen!
Um das Paket einem breiteren Anwenderkreis zugänglich zu machen, -wurden diverse Textelemente im Design parametrisiert. Eingaben, die -nicht NA sind, werden priorisiert. Werden Argumente zu Textelementen wie -Kontaktinformationen aber bei NA belassen, werden Werte aus einer -bestehenden und anpassbaren Nutzerkonfiguration substituiert. Das Paket -kommt mit einer Standardkonfiguration (“default”) mit dem folgendem -Inhalt:
-# Configuration file for statR
-statR_config_name: default
-
-# Contact information
-contactdetails:
- statR_organization: Statistisches Amt des Kantons Zürich
- statR_name: Datashop
- statR_phone: +41 43 259 75 00
- statR_email: datashop@statistik.zh.ch
- statR_homepage: http://www.statistik.zh.ch
- statR_openinghours:
- - Bürozeiten
- - Montag bis Freitag
- - 09:00 bis 12:00
- - 13:00 bis 16:00
-
-# Logo: this can be one of the values statzh or zh, or a path to an image
-logo:
- statR_logo: statzh
- statR_logo_width: 2.145
- statR_logo_height: 0.7865
-
-# Prefixes for strings
-prefixes:
- statR_prefix_date: "Aktualisiert am:"
- statR_prefix_author: "durch:"
- statR_prefix_phone: "Tel."
- statR_prefix_order_id: "Auftragsnr.:"
-
-# Default values
-defaults:
- statR_index_title: Inhalt
- statR_index_source: Statistisches Amt des Kantons Zürich
- statR_default_plot_width: 6
- statR_default_plot_height: 3
-
-# Miscellaneous
-statR_date_format: "%d.%m.%Y"Basierend auf dieser Vorlage können auch weitere Konfigurationen -erstellt werden. Anwendungsbeispiele:
-Bei der ersten Verwendung von statR wird mit der Funktion
-initUserConfigStore ein Verzeichnis “~/.config/R/statR”
-angelegt und eine Index-Datei erstellt. In dieser Datei werden der
-Konfigurationsname und der Pfad zur Konfigurationsdatei gespeichert.
Neue Konfigurationen müssen zunächst mit der Funktion
-addUserConfig registriert werden. Das folgende Beispiel
-demonstriert die Vorgehensweise:
-# Laden der Konfiguration als Listenobjekt
-new_config <- statR::readUserConfig("default")
-
-# Anpassung einzelner Eintraege
-new_config$statR_config_name <- "team_data"
-new_config$contactdetails$statR_name <- "Team Data"
-new_config$logo$statR_logo <- "zh"
-
-# Speichern & Registrierung der neuen Konfiguration
-yaml::write_yaml(new_config, "config/team_data.yaml")
-statR::addUserConfig("team_data", "config/team_data.yaml")
-
-# Anwendung
-mtcars_title <- "Motor trend car road tests"
-
-statR::quickXLSX(data = mtcars,
- file = "output/userconfig_demo",
- title = mtcars_title,
- source = mtcars_source,
- metadata = mtcars_metadata,
- config = "team_data",
- author = "Vorname Nachname")Schliesslich besteht noch die Möglichkeit, Konfigurationen zu
-modifizieren (updateUserConfig) oder zu löschen
-(removeUserConfig).
Bilder können gegenwärtig nur mit der @@ -469,7 +385,7 @@
+quickXLSX(data = mtcars, file = "output/quickXLSX_grouped.xlsx", title = mtcars_title, @@ -522,7 +438,7 @@Formatierung von Spalteninhalten
Das folgende Beispiel demonstriert den Prozess anhand des Merkmals “drat” (rear axle ratio):
-+mtcars_dataset <- mtcars class(mtcars_dataset$drat) <- "percentage" diff --git a/docs/articles/Sonstige_Funktionen.html b/docs/articles/Sonstige_Funktionen.html index 4a10213..5f53ebf 100644 --- a/docs/articles/Sonstige_Funktionen.html +++ b/docs/articles/Sonstige_Funktionen.html @@ -51,6 +51,9 @@
- + Benutzerkonfiguration +
+- Excel-Tabellen
- diff --git a/docs/articles/Visualisierungen.html b/docs/articles/Visualisierungen.html index 10f1c47..10865c6 100644 --- a/docs/articles/Visualisierungen.html +++ b/docs/articles/Visualisierungen.html @@ -51,6 +51,9 @@
- + Benutzerkonfiguration +
+- Excel-Tabellen
- diff --git a/docs/articles/Visualisierungen_files/figure-html/unnamed-chunk-14-1.png b/docs/articles/Visualisierungen_files/figure-html/unnamed-chunk-14-1.png index 8af2c7e..943f4c6 100644 Binary files a/docs/articles/Visualisierungen_files/figure-html/unnamed-chunk-14-1.png and b/docs/articles/Visualisierungen_files/figure-html/unnamed-chunk-14-1.png differ diff --git a/docs/articles/html_report_template.html b/docs/articles/html_report_template.html index d1bbf3a..2f43c14 100644 --- a/docs/articles/html_report_template.html +++ b/docs/articles/html_report_template.html @@ -51,6 +51,9 @@
- + Benutzerkonfiguration +
+- Excel-Tabellen
- diff --git a/docs/articles/img/aXLSX_1.PNG b/docs/articles/img/aXLSX_1.PNG new file mode 100644 index 0000000..29b42fe Binary files /dev/null and b/docs/articles/img/aXLSX_1.PNG differ diff --git a/docs/articles/img/aXLSX_2.PNG b/docs/articles/img/aXLSX_2.PNG new file mode 100644 index 0000000..14143c4 Binary files /dev/null and b/docs/articles/img/aXLSX_2.PNG differ diff --git a/docs/articles/img/datasetsXLSX_1.PNG b/docs/articles/img/datasetsXLSX_1.PNG new file mode 100644 index 0000000..733908e Binary files /dev/null and b/docs/articles/img/datasetsXLSX_1.PNG differ diff --git a/docs/articles/img/datasetsXLSX_2.PNG b/docs/articles/img/datasetsXLSX_2.PNG new file mode 100644 index 0000000..9472413 Binary files /dev/null and b/docs/articles/img/datasetsXLSX_2.PNG differ diff --git a/docs/articles/img/datasetsXLSX_3.PNG b/docs/articles/img/datasetsXLSX_3.PNG new file mode 100644 index 0000000..2898898 Binary files /dev/null and b/docs/articles/img/datasetsXLSX_3.PNG differ diff --git a/docs/articles/img/quickXLSX.PNG b/docs/articles/img/quickXLSX.PNG new file mode 100644 index 0000000..e11b81b Binary files /dev/null and b/docs/articles/img/quickXLSX.PNG differ diff --git a/docs/articles/img/quickXLSX_grouped.PNG b/docs/articles/img/quickXLSX_grouped.PNG new file mode 100644 index 0000000..9b74dcd Binary files /dev/null and b/docs/articles/img/quickXLSX_grouped.PNG differ diff --git a/docs/articles/img/quickXLSX_pct.PNG b/docs/articles/img/quickXLSX_pct.PNG new file mode 100644 index 0000000..076f388 Binary files /dev/null and b/docs/articles/img/quickXLSX_pct.PNG differ diff --git a/docs/articles/img/rmd_template.PNG b/docs/articles/img/rmd_template.PNG new file mode 100644 index 0000000..1e28ca5 Binary files /dev/null and b/docs/articles/img/rmd_template.PNG differ diff --git a/docs/articles/img/sample_report.PNG b/docs/articles/img/sample_report.PNG new file mode 100644 index 0000000..06c6be5 Binary files /dev/null and b/docs/articles/img/sample_report.PNG differ diff --git a/docs/articles/img/zh_report.PNG b/docs/articles/img/zh_report.PNG new file mode 100644 index 0000000..c30a3aa Binary files /dev/null and b/docs/articles/img/zh_report.PNG differ diff --git a/docs/articles/index.html b/docs/articles/index.html index f72dd8e..80226ea 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -32,6 +32,9 @@
- + Benutzerkonfiguration +
+- Excel-Tabellen
- @@ -69,7 +72,9 @@
Articles
All vignettes
-
- Excel-Tabellen
+
- Benutzerkonfiguration
+- +
- Excel-Tabellen
- Sonstige Funktionen
- diff --git a/docs/authors.html b/docs/authors.html index d9fc6a1..9f66ebc 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -32,6 +32,9 @@
- + Benutzerkonfiguration +
+- Excel-Tabellen
- diff --git a/docs/index.html b/docs/index.html index e588563..7ded055 100644 --- a/docs/index.html +++ b/docs/index.html @@ -51,6 +51,9 @@
- + Benutzerkonfiguration +
+- Excel-Tabellen
- diff --git a/docs/news/index.html b/docs/news/index.html index 25ff484..f6f83ca 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -32,6 +32,9 @@
- + Benutzerkonfiguration +
+- Excel-Tabellen
- diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index cc62a33..1c214de 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -2,9 +2,10 @@ pandoc: 3.1.1 pkgdown: 2.0.7 pkgdown_sha: ~ articles: + Benutzerkonfiguration: Benutzerkonfiguration.html Excel-Tabellen: Excel-Tabellen.html Sonstige_Funktionen: Sonstige_Funktionen.html Visualisierungen: Visualisierungen.html html_report_template: html_report_template.html -last_built: 2024-02-09T08:57Z +last_built: 2024-02-27T12:13Z diff --git a/docs/reference/aXLSX.html b/docs/reference/aXLSX.html index 2ee14bb..676f25e 100644 --- a/docs/reference/aXLSX.html +++ b/docs/reference/aXLSX.html @@ -34,6 +34,9 @@
- + Benutzerkonfiguration +
+- Excel-Tabellen
- diff --git a/docs/reference/addUserConfig.html b/docs/reference/addUserConfig.html new file mode 100644 index 0000000..dc0b9ca --- /dev/null +++ b/docs/reference/addUserConfig.html @@ -0,0 +1,120 @@ + +
Registrieren eines neuen Header-Config-Yaml Files — addUserConfig • statR + + +++ + + + + + + + diff --git a/docs/reference/add_attribute.html b/docs/reference/add_attribute.html new file mode 100644 index 0000000..8066966 --- /dev/null +++ b/docs/reference/add_attribute.html @@ -0,0 +1,212 @@ + + ++ + + ++++ + + statR + 2.4.1 + ++ +++
- + Reference +
+- + + Articles + + + +
+
- + Benutzerkonfiguration +
+- + Excel-Tabellen +
+- + Sonstige Funktionen +
+- + Visualisierungen +
+- + HTML Dokumente im ZH.CH-Design +
+- + Changelog +
+
- + + + + +
+++ + ++ + ++++ +Registrieren eines neuen Header-Config-Yaml Files
+++ ++addUserConfig(name = "default", path = NULL, store_path = "~/.config/R/statR")++ +Arguments
+
- name
+- + + +
unter welchem namen soll die Header-Konfiguration abrufbar sein.
- path
+- + + +
Pfad zum Header-Konfigurations-Yaml-File
- store_path
+- + +
Pfad unter welchem das Konfigurationsfile fuer das registrieren +von Header-Config-Yaml-Files liegen soll
++Helper functions for adding attributes to input objects — add_attribute • statR + + +++ + + + + + + + diff --git a/docs/reference/check_for_attributes.html b/docs/reference/check_for_attributes.html new file mode 100644 index 0000000..e8d321d --- /dev/null +++ b/docs/reference/check_for_attributes.html @@ -0,0 +1,113 @@ + + ++ + + ++++ + + statR + 2.4.1 + ++ +++
- + Reference +
+- + + Articles + + + +
+
- + Benutzerkonfiguration +
+- + Excel-Tabellen +
+- + Sonstige Funktionen +
+- + Visualisierungen +
+- + HTML Dokumente im ZH.CH-Design +
+- + Changelog +
+
- + + + + +
+++ + +++++ +Helper functions for adding attributes to input objects
+ Source:R/content.R++add_attribute.Rd++ +A set of helper functions which serve the purpose of allowing + users to assign information like sheetnames, titles, sources, metadata, and + more to an object. These attributes are then used in place of the function + arguments.
+++ ++add_attribute(object, what, value) + +# S3 method for default +add_attribute(object, what, value) + +# S3 method for Content +add_attribute(object, what, value) + +add_sheetname(object, value) + +add_title(object, value) + +add_source(object, value) + +add_metadata(object, value) + +add_grouplines(object, value) + +add_group_names(object, value) + +add_plot_size(object, value)++Arguments
+
- object
+- + + +
The object to add an attribute to
- value
+- + + +
A value
- prefix
+- + + +
A prefix, default to NULL
- collapse
+- + +
Separator to collapse character vectors on, defaults to NULL
++ +Details
++
add_sheetname: Adds a sheetname.+
add_title: Adds a title+
add_source: Adds a source. Behavior can be modified further via the + prefix and collapse argument. Setting collapse to a value other than NULL + will result in the input provided in value being concatenated.+
add_metadata: Adds metadata. Behavior can be modified further via the + prefix and collapse argument, just like withadd_source.+
add_grouplines: Adds group lines. Throws an error if input object is + not a data.frame.+
add_group_names: Adds group names. Throws an error if group lines + have not been set.+
add_plot_height: Adds plot height. Throws an error if input object is + not a valid plot type.+
add_plot_width: Adds plot width. Throws an error if input object is + not a valid plot type.+
add_plot_size: Assigns both height and width in one call. Expects a + vector of length 2, with the first element corresponding to width, and the + second to height.++Examples
++library(dplyr) +#> +#> Attaching package: ‘dplyr’ +#> The following objects are masked from ‘package:stats’: +#> +#> filter, lag +#> The following objects are masked from ‘package:base’: +#> +#> intersect, setdiff, setequal, union +library(ggplot2) + +# Load data and assign attributes in one pipeline +df <- mtcars %>% + add_sheetname("Cars") %>% + add_title("Motor Trend Car Road Tests") %>% + add_source( + c("Henderson and Velleman (1981),", + "Building multiple regression models interactively.", + "Biometrics, 37, 391–411.")) %>% + add_metadata( + c("The data was extracted from the 1974 Motor", + "Trend US magazine and comprises fuel consumption", + "and 10 aspects of automobile design and", + "performance for 32 automobiles (1973–74 models).")) + +# Create a plot and assign attributes in one pipeline +plt <- (ggplot(mtcars) + + geom_histogram(aes(x = hp))) %>% + add_sheetname("PS") %>% + add_title("Histogram of horsepower") %>% + add_plot_size(c(6, 3)) + +# Generate outputfile using minimal call +if (FALSE) { +datasetsXLSX( + file = tempfile(fileext = ".xlsx"), + datasets = list(df, plt)) +} +++Check for presence of keyword attributes in input data.frame — check_for_attributes • statR + + +++ + + + + + + + diff --git a/docs/reference/datasetsXLSX.html b/docs/reference/datasetsXLSX.html index 9d9915d..ee486b6 100644 --- a/docs/reference/datasetsXLSX.html +++ b/docs/reference/datasetsXLSX.html @@ -35,6 +35,9 @@ ++ + + ++++ + + statR + 2.4.1 + ++ +++
- + Reference +
+- + + Articles + + + +
+
- + Benutzerkonfiguration +
+- + Excel-Tabellen +
+- + Sonstige Funktionen +
+- + Visualisierungen +
+- + HTML Dokumente im ZH.CH-Design +
+- + Changelog +
+
- + + + + +
+++ + +++++ +Check for presence of keyword attributes in input data.frame
+ Source:R/content.R++check_for_attributes.Rd++ +A function which checks for presence of certain attributes in an input +data.frame.
+++ ++check_for_attributes(object)++ +Arguments
+
- object
+- + +
Input data.frame
++
- + Benutzerkonfiguration +
+- Excel-Tabellen
- diff --git a/docs/reference/display.html b/docs/reference/display.html index 5019616..7f4bad9 100644 --- a/docs/reference/display.html +++ b/docs/reference/display.html @@ -32,6 +32,9 @@
- + Benutzerkonfiguration +
+- Excel-Tabellen
- diff --git a/docs/reference/display.statcol.all.html b/docs/reference/display.statcol.all.html index b4b398e..eedd833 100644 --- a/docs/reference/display.statcol.all.html +++ b/docs/reference/display.statcol.all.html @@ -32,6 +32,9 @@
- + Benutzerkonfiguration +
+- Excel-Tabellen
- diff --git a/docs/reference/excelIndexToRowCol.html b/docs/reference/excelIndexToRowCol.html new file mode 100644 index 0000000..4241b08 --- /dev/null +++ b/docs/reference/excelIndexToRowCol.html @@ -0,0 +1,119 @@ + +
Convert Excel index to row/column indices — excelIndexToRowCol • statR + + +++ + + + + + + + diff --git a/docs/reference/extract_attribute.html b/docs/reference/extract_attribute.html new file mode 100644 index 0000000..bee2c2f --- /dev/null +++ b/docs/reference/extract_attribute.html @@ -0,0 +1,133 @@ + + ++ + + ++++ + + statR + 2.4.1 + ++ +++
- + Reference +
+- + + Articles + + + +
+
- + Benutzerkonfiguration +
+- + Excel-Tabellen +
+- + Sonstige Funktionen +
+- + Visualisierungen +
+- + HTML Dokumente im ZH.CH-Design +
+- + Changelog +
+
- + + + + +
+++ + ++ + ++++ +Converts an Excel style index (e.g. A1) into numeric row and + column indices. Handles cells (A1) as well as matrices (A1:B2)
+++ ++excelIndexToRowCol(index)++Arguments
+
- index
+- + +
A Microsoft Excel style index (see details)
++ +Value
+ + +A list containing row indices and column indices
+++Extract attributes from target object — extract_attribute • statR + + +++ + + + + + + + diff --git a/docs/reference/flush_left-1.png b/docs/reference/flush_left-1.png new file mode 100644 index 0000000..3ee4f89 Binary files /dev/null and b/docs/reference/flush_left-1.png differ diff --git a/docs/reference/flush_left.html b/docs/reference/flush_left.html index 4e2d0af..74279e5 100644 --- a/docs/reference/flush_left.html +++ b/docs/reference/flush_left.html @@ -33,6 +33,9 @@ ++ + + ++++ + + statR + 2.4.1 + ++ +++
- + Reference +
+- + + Articles + + + +
+
- + Benutzerkonfiguration +
+- + Excel-Tabellen +
+- + Sonstige Funktionen +
+- + Visualisierungen +
+- + HTML Dokumente im ZH.CH-Design +
+- + Changelog +
+
- + + + + +
+++ + ++ + ++++ +Function to extract attributes from objects. +
+extract_attributeexpects the input object to be the target. When + the target object is nested in a list (as is the case in +datasetsXLSX),extract_attributesshould be used instead.++ ++extract_attribute(object, which, required_val = FALSE) + +extract_attributes(object_list, which, required_val = FALSE)++ +Arguments
+
- object
+- + + +
Object to extract attribute from. In practice a data.frame, +ggplot object, or a character string providing a path to an image.
- which
+- + + +
Name of the attribute to extract.
- required_val
+- + + +
Boolean, if TRUE tries to look up a default in global +options if attribute not found, and raises an error if none was defined.
- object_list
+- + +
A list of objects of arbitrary types.
++
- + Benutzerkonfiguration +
+- Excel-Tabellen
- diff --git a/docs/reference/index.html b/docs/reference/index.html index eb500e4..540cf57 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -32,6 +32,9 @@
- + Benutzerkonfiguration +
+- Excel-Tabellen
- diff --git a/docs/reference/initUserConfigStore.html b/docs/reference/initUserConfigStore.html new file mode 100644 index 0000000..d7f3058 --- /dev/null +++ b/docs/reference/initUserConfigStore.html @@ -0,0 +1,118 @@ + +
Initialisiert die Excel-Header-Konfiguration — initUserConfigStore • statR + + +++ + + + + + + + diff --git a/docs/reference/inputHelperContactInfo.html b/docs/reference/inputHelperContactInfo.html new file mode 100644 index 0000000..87e502c --- /dev/null +++ b/docs/reference/inputHelperContactInfo.html @@ -0,0 +1,123 @@ + + ++ + + ++++ + + statR + 2.4.1 + ++ +++
- + Reference +
+- + + Articles + + + +
+
- + Benutzerkonfiguration +
+- + Excel-Tabellen +
+- + Sonstige Funktionen +
+- + Visualisierungen +
+- + HTML Dokumente im ZH.CH-Design +
+- + Changelog +
+
- + + + + +
+++ + ++ + ++++ +Die Header-Konfiguration wird ueber globale Options geloest, welche in +einem Yaml file definiert werden. Per default wird die Konfiguration des +Packages angezogen. Es besteht die Moeglichkeit, eine eigene Konfiguration +zu hinterlegen. Siehe dazu die Funktion: addUserConfig()
+++ ++initUserConfigStore(store_path = "~/.config/R/statR")++ +Arguments
+
- store_path
+- + +
Pfad unter welchem das Konfigurationsfile fuer das registrieren +von Header-Config-Yaml-Files liegen soll
++Construct a vector with contact information from defaults — inputHelperContactInfo • statR + + +++ + + + + + + + diff --git a/docs/reference/inputHelperHomepage.html b/docs/reference/inputHelperHomepage.html new file mode 100644 index 0000000..ede27eb --- /dev/null +++ b/docs/reference/inputHelperHomepage.html @@ -0,0 +1,117 @@ + + ++ + + ++++ + + statR + 2.4.1 + ++ +++
- + Reference +
+- + + Articles + + + +
+
- + Benutzerkonfiguration +
+- + Excel-Tabellen +
+- + Sonstige Funktionen +
+- + Visualisierungen +
+- + HTML Dokumente im ZH.CH-Design +
+- + Changelog +
+
- + + + + +
+++ + +++++ +Construct a vector with contact information from defaults
+ Source:R/helper.R++inputHelperContactInfo.Rd++ +A helper function which constructs a character vector from the contact +information defined in the user profile. If
+compact = TRUE, the +organization is dropped, and the name and phone number are displayed in the +same row.++ ++inputHelperContactInfo(compact = FALSE)++Arguments
+
- compact
+- + +
A boolean. If TRUE, a shortened version is displayed
++ +Value
+ + +A character vector
+++Set homepage to a hyperlink — inputHelperHomepage • statR + + +++ + + + + + + + diff --git a/docs/reference/insert_hyperlinks.html b/docs/reference/insert_hyperlinks.html new file mode 100644 index 0000000..8797f10 --- /dev/null +++ b/docs/reference/insert_hyperlinks.html @@ -0,0 +1,133 @@ + + ++ + + ++++ + + statR + 2.4.1 + ++ +++
- + Reference +
+- + + Articles + + + +
+
- + Benutzerkonfiguration +
+- + Excel-Tabellen +
+- + Sonstige Funktionen +
+- + Visualisierungen +
+- + HTML Dokumente im ZH.CH-Design +
+- + Changelog +
+
- + + + + +
+++ + ++ + ++++ +Formats homepage as a hyperlink object.
+++ ++inputHelperHomepage(homepage)++Arguments
+
- homepage
+- + +
A character string
++ +Value
+ + +A character string or a 'hyperlink' object
+++Insert hyperlinks — insert_hyperlinks • statR + + +++ + + + + + + + diff --git a/docs/reference/insert_index_hyperlinks.html b/docs/reference/insert_index_hyperlinks.html new file mode 100644 index 0000000..6e5c3f2 --- /dev/null +++ b/docs/reference/insert_index_hyperlinks.html @@ -0,0 +1,133 @@ + + ++ + + ++++ + + statR + 2.4.1 + ++ +++
- + Reference +
+- + + Articles + + + +
+
- + Benutzerkonfiguration +
+- + Excel-Tabellen +
+- + Sonstige Funktionen +
+- + Visualisierungen +
+- + HTML Dokumente im ZH.CH-Design +
+- + Changelog +
+
- + + + + +
+++ + ++ + ++++ +Function for inserting hyperlinks within an openxlsx Workbook. + Provides support for links to external .xlsx.
+++ ++insert_hyperlinks(wb, sheetname, text, where, start_row = 15, file = NULL)++ +Arguments
+
- wb
+- + + +
workbook object to add new worksheet to.
- sheetname
+- + + +
Names of sheets to create hyperlinks to
- text
+- + + +
Text to display in the cell with the hyperlink
- where
+- + + +
Name of the worksheet where the hyperlinks should be inserted
- start_row
+- + + +
First row from which hyperlink should be inserted
- file
+- + +
External file. Default: NULL
++Insert hyperlinks with titles and sheetnames — insert_index_hyperlinks • statR + + +++ + + + + + + + diff --git a/docs/reference/insert_index_sheet.html b/docs/reference/insert_index_sheet.html new file mode 100644 index 0000000..796f9be --- /dev/null +++ b/docs/reference/insert_index_sheet.html @@ -0,0 +1,181 @@ + + ++ + + ++++ + + statR + 2.4.1 + ++ +++
- + Reference +
+- + + Articles + + + +
+
- + Benutzerkonfiguration +
+- + Excel-Tabellen +
+- + Sonstige Funktionen +
+- + Visualisierungen +
+- + HTML Dokumente im ZH.CH-Design +
+- + Changelog +
+
- + + + + +
+++ + +++++ +Insert hyperlinks with titles and sheetnames
+ Source:R/insert_hyperlinks.R++insert_index_hyperlinks.Rd++ +Function for inserting hyperlinks within an openxlsx Workbook
+++ ++insert_index_hyperlinks( + wb, + sheetname, + title, + index_sheet_name = "Index", + sheet_start_row = 15 +)++ +Arguments
+
- wb
+- + + +
workbook object to add new worksheet to.
- sheetname
+- + + +
Names of sheets to create hyperlinks to
- title
+- + + +
Titles of Hyperlinks
- index_sheet_name
+- + + +
Name of sheet where hyperlink should be created
- sheet_start_row
+- + +
Initial row after which hyperlinks should be created
++Insert empty index sheet — insert_index_sheet • statR + + +++ + + + + + + + diff --git a/docs/reference/insert_metadata_sheet.html b/docs/reference/insert_metadata_sheet.html index a777145..f5b6998 100644 --- a/docs/reference/insert_metadata_sheet.html +++ b/docs/reference/insert_metadata_sheet.html @@ -33,6 +33,9 @@ ++ + + ++++ + + statR + 2.4.1 + ++ +++
- + Reference +
+- + + Articles + + + +
+
- + Benutzerkonfiguration +
+- + Excel-Tabellen +
+- + Sonstige Funktionen +
+- + Visualisierungen +
+- + HTML Dokumente im ZH.CH-Design +
+- + Changelog +
+
- + + + + +
+++ + ++ + ++++ +Function which initializes an empty index sheet. The function is + intended to be called at the beginning of a workflow (just after the + initialization of the Workbook object), and paired with the function +
+insert_index_hyperlinks().++ ++insert_index_sheet( + wb, + sheetname = "Index", + title, + auftrag_id, + logo = getOption("statR_logo"), + contactdetails = inputHelperContactInfo(), + homepage = getOption("statR_homepage"), + openinghours = getOption("statR_openinghours"), + source = getOption("statR_index_source"), + author = "user" +)++Arguments
+
- wb
+- + + +
workbook object to add new worksheet to.
- sheetname
+- + + +
Names of the worksheet in output file. Note that this name +will be truncated to 31 characters, must be unique, and cannot contain +some special characters (namely the following: /, \, ?, *, :, [, ]).
- title
+- + + +
title to be put above the data.
- auftrag_id
+- + + +
Order ID
- logo
+- + + +
File path to the logo to be included in the index-sheet. +Defaults to the logo of the Statistical Office of Kanton Zurich. This can +either be overridden with a path to an image file, or configured in a user +profile.
- contactdetails
+- + + +
Character vector with contact information to be displayed +on the title sheet. By default uses
inputHelperContactInfo()to +construct it based on values defined in the active user configuration.- homepage
+- + + +
Homepage of data publisher. Default can be adjusted via user +configuration.
- openinghours
+- + + +
statzh or a character string or vector with opening hours
- source
+- + + +
source of the data. Default can be adjusted via user profiles
- author
+- + +
defaults to the last two letters (initials) or numbers of the +internal user name.
++ +Details
+The logo can be customized via the `statR_logo` global option. This + should point to the path of the logo file. Other options such as the image + size in the final .xlsx can either be changed via the options + `statR_logo_width` and `statR_logo_height`, or set along with contact + information in a custom profile.
+++
- + Benutzerkonfiguration +
+- Excel-Tabellen
- diff --git a/docs/reference/insert_second_header.html b/docs/reference/insert_second_header.html new file mode 100644 index 0000000..66dd574 --- /dev/null +++ b/docs/reference/insert_second_header.html @@ -0,0 +1,145 @@ + +
insert_second_header() — insert_second_header • statR + + +++ + + + + + + + diff --git a/docs/reference/insert_worksheet.html b/docs/reference/insert_worksheet.html index b243982..4ea0edd 100644 --- a/docs/reference/insert_worksheet.html +++ b/docs/reference/insert_worksheet.html @@ -38,6 +38,9 @@ ++ + + ++++ + + statR + 2.4.1 + ++ +++
- + Reference +
+- + + Articles + + + +
+
- + Benutzerkonfiguration +
+- + Excel-Tabellen +
+- + Sonstige Funktionen +
+- + Visualisierungen +
+- + HTML Dokumente im ZH.CH-Design +
+- + Changelog +
+
- + + + + +
+++ + ++ + ++++ +Function to add a second header row
+++ ++insert_second_header( + wb, + sheetname, + data_start_row, + group_names, + grouplines, + data +)++ +Arguments
+
- wb
+- + + +
workbook object to add new worksheet to.
- sheetname
+- + + +
Names of the worksheet in output file. Note that this name +will be truncated to 31 characters, must be unique, and cannot contain +some special characters (namely the following: /, \, ?, *, :, [, ]).
- data_start_row
+- + + +
Row index for first row with data
- group_names
+- + + +
A vector of names for groups to be displayed in a +secondary header. Should be of the same length as grouplines, and cannot +be used unless these are set. Defaults to NA, meaning no secondary header +is created.
- grouplines
+- + + +
Can be used to visually group variables. Values should +either correspond to numeric column indices or column names, denoting the +first variable in a group. Defaults to NA, meaning no lines are added.
- data
+- + +
data to be included.
++
- + Benutzerkonfiguration +
+- Excel-Tabellen
- diff --git a/docs/reference/insert_worksheet_image.html b/docs/reference/insert_worksheet_image.html index e4bff14..d1ec325 100644 --- a/docs/reference/insert_worksheet_image.html +++ b/docs/reference/insert_worksheet_image.html @@ -34,6 +34,9 @@
- + Benutzerkonfiguration +
+- Excel-Tabellen
- diff --git a/docs/reference/interpolate2.html b/docs/reference/interpolate2.html index 6a53255..261fa9a 100644 --- a/docs/reference/interpolate2.html +++ b/docs/reference/interpolate2.html @@ -32,6 +32,9 @@
- + Benutzerkonfiguration +
+- Excel-Tabellen
- diff --git a/docs/reference/missingToNull.html b/docs/reference/missingToNull.html new file mode 100644 index 0000000..12369a0 --- /dev/null +++ b/docs/reference/missingToNull.html @@ -0,0 +1,105 @@ + +
Convert missing input to NULL — missingToNull • statR + + +++ + + + + + + + diff --git a/docs/reference/namedRegionBoundary.html b/docs/reference/namedRegionBoundary.html new file mode 100644 index 0000000..280b64d --- /dev/null +++ b/docs/reference/namedRegionBoundary.html @@ -0,0 +1,133 @@ + + ++ + + ++++ + + statR + 2.4.1 + ++ +++
- + Reference +
+- + + Articles + + + +
+
- + Benutzerkonfiguration +
+- + Excel-Tabellen +
+- + Sonstige Funktionen +
+- + Visualisierungen +
+- + HTML Dokumente im ZH.CH-Design +
+- + Changelog +
+
- + + + + +
+++ + ++ + ++++ +Convert missing input to NULL
+++ + ++missingToNull(input_value)++Functions to determine the outer boundaries of named regions — namedRegionFirstRow • statR + + +++ + + + + + + + diff --git a/docs/reference/namedRegionExtent.html b/docs/reference/namedRegionExtent.html new file mode 100644 index 0000000..f28bcd4 --- /dev/null +++ b/docs/reference/namedRegionExtent.html @@ -0,0 +1,137 @@ + + ++ + + ++++ + + statR + 2.4.1 + ++ +++
- + Reference +
+- + + Articles + + + +
+
- + Benutzerkonfiguration +
+- + Excel-Tabellen +
+- + Sonstige Funktionen +
+- + Visualisierungen +
+- + HTML Dokumente im ZH.CH-Design +
+- + Changelog +
+
- + + + + +
+++ + +++++ +Functions to determine the outer boundaries of named regions
+ Source:R/helper.R++namedRegionBoundary.Rd++ +Methods for determining the first and last index of + a namedRegion in row and column directions.
+++ ++namedRegionFirstRow(wb, sheetname, region_name = NULL) + +namedRegionLastRow(wb, sheetname, region_name = NULL) + +namedRegionFirstCol(wb, sheetname, region_name = NULL) + +namedRegionLastCol(wb, sheetname, region_name = NULL)++Arguments
+
- wb
+- + + +
A workbook object
- sheetname
+- + + +
Name of a worksheet
- region_name
+- + +
names of regions in Workbook.
++ +Value
+ + +Numeric value
+++Determine the row and column extent of named regions — namedRegionExtent • statR + + +++ + + + + + + + diff --git a/docs/reference/namedRegionExtent1D.html b/docs/reference/namedRegionExtent1D.html new file mode 100644 index 0000000..db1d648 --- /dev/null +++ b/docs/reference/namedRegionExtent1D.html @@ -0,0 +1,127 @@ + + ++ + + ++++ + + statR + 2.4.1 + ++ +++
- + Reference +
+- + + Articles + + + +
+
- + Benutzerkonfiguration +
+- + Excel-Tabellen +
+- + Sonstige Funktionen +
+- + Visualisierungen +
+- + HTML Dokumente im ZH.CH-Design +
+- + Changelog +
+
- + + + + +
+++ + +++++ +Determine the row and column extent of named regions
+ Source:R/helper.R++namedRegionExtent.Rd++ +Get extent of a named region in a workbook object
+++ ++namedRegionExtent(wb, sheetname, region_name = NULL, which = "both")++Arguments
+
- wb
+- + + +
A workbook object
- sheetname
+- + + +
Name of a worksheet
- region_name
+- + + +
names of regions in Workbook.
- which
+- + +
either "row", "col", or "both" (default).
++Value
+ + +A list with two numeric vectors row and col, containing + row and column indices.
+++ +Details
+If a single name is provided, returns the extent of the associated + named region. If a character vector is provided, the combined extent is + returned instead. If left at default (NULL), the combined extent of all + regions is returned.
+++Determine the extent of a named region in a particular direction — namedRegionRowExtent • statR + + +++ + + + + + + + diff --git a/docs/reference/quickXLSX.html b/docs/reference/quickXLSX.html index 2de9cab..adc13db 100644 --- a/docs/reference/quickXLSX.html +++ b/docs/reference/quickXLSX.html @@ -33,6 +33,9 @@ ++ + + ++++ + + statR + 2.4.1 + ++ +++
- + Reference +
+- + + Articles + + + +
+
- + Benutzerkonfiguration +
+- + Excel-Tabellen +
+- + Sonstige Funktionen +
+- + Visualisierungen +
+- + HTML Dokumente im ZH.CH-Design +
+- + Changelog +
+
- + + + + +
+++ + +++++ +Determine the extent of a named region in a particular direction
+ Source:R/helper.R++namedRegionExtent1D.Rd++ +Get row or column extent of a named region in a workbook object.
+++ ++namedRegionRowExtent(wb, sheetname, region_name = NULL) + +namedRegionColumnExtent(wb, sheetname, region_name = NULL)++Arguments
+
- wb
+- + + +
A workbook object
- sheetname
+- + + +
Name of a worksheet
- region_name
+- + +
names of regions in Workbook.
++ +Value
+ + +A numeric vector of indices
+++
- + Benutzerkonfiguration +
+- Excel-Tabellen
- diff --git a/docs/reference/quick_sum.html b/docs/reference/quick_sum.html index c103b0f..65cb60a 100644 --- a/docs/reference/quick_sum.html +++ b/docs/reference/quick_sum.html @@ -32,6 +32,9 @@
- + Benutzerkonfiguration +
+- Excel-Tabellen
- diff --git a/docs/reference/readUserConfig.html b/docs/reference/readUserConfig.html new file mode 100644 index 0000000..8100c9b --- /dev/null +++ b/docs/reference/readUserConfig.html @@ -0,0 +1,116 @@ + +
Liest das Header-Konfigurations-Yaml-File — readUserConfig • statR + + +++ + + + + + + + diff --git a/docs/reference/readUserConfigStore.html b/docs/reference/readUserConfigStore.html new file mode 100644 index 0000000..4b573ff --- /dev/null +++ b/docs/reference/readUserConfigStore.html @@ -0,0 +1,117 @@ + + ++ + + ++++ + + statR + 2.4.1 + ++ +++
- + Reference +
+- + + Articles + + + +
+
- + Benutzerkonfiguration +
+- + Excel-Tabellen +
+- + Sonstige Funktionen +
+- + Visualisierungen +
+- + HTML Dokumente im ZH.CH-Design +
+- + Changelog +
+
- + + + + +
+++ + ++ + ++++ +Liest das Header-Konfigurations-Yaml-File
+++ ++readUserConfig(name = "default", store_path = "~/.config/R/statR")++ +Arguments
+
- name
+- + + +
welches file soll angezogen werden
- store_path
+- + +
Pfad unter welchem das Konfigurationsfile fuer das registrieren +von Header-Config-Yaml-Files liegen soll
++Liest das Konfigurationsfile in welchem die Pfade zum Header-Config file +hinterlegt sind — readUserConfigStore • statR + + +++ + + + + + + + diff --git a/docs/reference/removeUserConfig.html b/docs/reference/removeUserConfig.html new file mode 100644 index 0000000..c6434a9 --- /dev/null +++ b/docs/reference/removeUserConfig.html @@ -0,0 +1,116 @@ + + ++ + + ++++ + + statR + 2.4.1 + ++ +++
- + Reference +
+- + + Articles + + + +
+
- + Benutzerkonfiguration +
+- + Excel-Tabellen +
+- + Sonstige Funktionen +
+- + Visualisierungen +
+- + HTML Dokumente im ZH.CH-Design +
+- + Changelog +
+
- + + + + +
+++ + +++++ +Liest das Konfigurationsfile in welchem die Pfade zum Header-Config file +hinterlegt sind
+ Source:R/user_config.R++readUserConfigStore.Rd++ +Liest das Konfigurationsfile in welchem die Pfade zum Header-Config file +hinterlegt sind
+++ ++readUserConfigStore(store_path = "~/.config/R/statR")++ +Arguments
+
- store_path
+- + +
Pfad unter welchem das Konfigurationsfile fuer das registrieren +von Header-Config-Yaml-Files liegen soll
++Loeschen eines Konfigurations-Eintrages — removeUserConfig • statR + + +++ + + + + + + + diff --git a/docs/reference/splitXLSX.html b/docs/reference/splitXLSX.html index c43a5da..0db244e 100644 --- a/docs/reference/splitXLSX.html +++ b/docs/reference/splitXLSX.html @@ -33,6 +33,9 @@ ++ + + ++++ + + statR + 2.4.1 + ++ +++
- + Reference +
+- + + Articles + + + +
+
- + Benutzerkonfiguration +
+- + Excel-Tabellen +
+- + Sonstige Funktionen +
+- + Visualisierungen +
+- + HTML Dokumente im ZH.CH-Design +
+- + Changelog +
+
- + + + + +
+++ + ++ + ++++ +Loeschen eines Konfigurations-Eintrages
+++ ++removeUserConfig(name, store_path = "~/.config/R/statR")++ +Arguments
+
- name
+- + + +
Welcher registrierte Eintrag soll geloescht werden
- store_path
+- + +
Pfad unter welchem das Konfigurationsfile fuer das registrieren +von Header-Config-Yaml-Files liegen soll
++
- + Benutzerkonfiguration +
+- Excel-Tabellen
- diff --git a/docs/reference/theme_stat.html b/docs/reference/theme_stat.html index 101172d..a1b917b 100644 --- a/docs/reference/theme_stat.html +++ b/docs/reference/theme_stat.html @@ -35,6 +35,9 @@
- + Benutzerkonfiguration +
+- Excel-Tabellen
- diff --git a/docs/reference/updateUserConfig.html b/docs/reference/updateUserConfig.html new file mode 100644 index 0000000..4a27c43 --- /dev/null +++ b/docs/reference/updateUserConfig.html @@ -0,0 +1,120 @@ + +
Anpassen eines Header-Config-Yaml-Files-Pfades — updateUserConfig • statR + + +++ + + + + + + + diff --git a/docs/reference/writeText.html b/docs/reference/writeText.html new file mode 100644 index 0000000..0364de9 --- /dev/null +++ b/docs/reference/writeText.html @@ -0,0 +1,141 @@ + + ++ + + ++++ + + statR + 2.4.1 + ++ +++
- + Reference +
+- + + Articles + + + +
+
- + Benutzerkonfiguration +
+- + Excel-Tabellen +
+- + Sonstige Funktionen +
+- + Visualisierungen +
+- + HTML Dokumente im ZH.CH-Design +
+- + Changelog +
+
- + + + + +
+++ + ++ + ++++ +Anpassen eines Header-Config-Yaml-Files-Pfades
+++ ++updateUserConfig(name, path, store_path = "~/.config/R/statR")++ +Arguments
+
- name
+- + + +
Zu welchem Eintrag moechtest du den Pfad anpassen
- path
+- + + +
Pfad zum Header-Konfigurations-Yaml-File
- store_path
+- + +
Pfad unter welchem das Konfigurationsfile fuer das registrieren +von Header-Config-Yaml-Files liegen soll
++Compact function to write and format text — writeText • statR + + +++ + + + + + + + diff --git a/docs/reference/zhpal.html b/docs/reference/zhpal.html index ed1852a..323c15b 100644 --- a/docs/reference/zhpal.html +++ b/docs/reference/zhpal.html @@ -35,6 +35,9 @@ ++ + + ++++ + + statR + 2.4.1 + ++ +++
- + Reference +
+- + + Articles + + + +
+
- + Benutzerkonfiguration +
+- + Excel-Tabellen +
+- + Sonstige Funktionen +
+- + Visualisierungen +
+- + HTML Dokumente im ZH.CH-Design +
+- + Changelog +
+
- + + + + +
+++ + ++ + ++++ +A shorthand function for
+++ ++writeText(wb, sheetname, x, row, column, style, name)++Arguments
+
- wb
+- + + +
A workbook object
- sheetname
+- + + +
A sheetname
- x
+- + + +
Input
- row
+- + + +
The row at which to insert text
- column
+- + + +
The column at which to insert text. Can be a vector.
- style
+- + + +
A style object as defined by openxlsx::createStyle
- name
+- + +
A name to assign to the text. Note that this has to be unique
++ +Details
+Facilitates the process of inserting text content into workbooks. This +function integrates operations openxlsx::writeData and openxlsx::addStyle, +providing a convenience function for text blocks.
+++
- + Benutzerkonfiguration +
+- Excel-Tabellen
- diff --git a/docs/sitemap.xml b/docs/sitemap.xml new file mode 100644 index 0000000..2ca1cee --- /dev/null +++ b/docs/sitemap.xml @@ -0,0 +1,144 @@ + +
+ diff --git a/inst/extdata/config/default.yaml b/inst/extdata/config/default.yaml index ff8337e..009ff43 100644 --- a/inst/extdata/config/default.yaml +++ b/inst/extdata/config/default.yaml @@ -29,8 +29,9 @@ prefixes: # Default values defaults: - statR_index_title: Inhalt + statR_index_title: Auswertung statR_index_source: Statistisches Amt des Kantons Zürich + statR_index_toc_title: Inhalt statR_default_plot_width: 6 statR_default_plot_height: 3 diff --git a/man/datasetsXLSX.Rd b/man/datasetsXLSX.Rd index c555ade..555a540 100644 --- a/man/datasetsXLSX.Rd +++ b/man/datasetsXLSX.Rd @@ -17,6 +17,7 @@ datasetsXLSX( plot_height = NULL, index_title = NA, index_source = NA, + index_toc_title = NA, logo = NA, contactdetails = NA, homepage = NA, @@ -64,6 +65,8 @@ in inches (1 inch = 2.54 cm), or a list of the same length as `datasets`} \item{index_source}{Source to be shown below the index title.} +\item{index_toc_title}{Title shown above the table of content.} + \item{logo}{File path to the logo to be included in the index-sheet. Defaults to the logo of the Statistical Office of Kanton Zurich. This can either be overridden with a path to an image file, or configured in a user diff --git a/man/get_user_config.Rd b/man/get_user_config.Rd new file mode 100644 index 0000000..0430dba --- /dev/null +++ b/man/get_user_config.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/user_config.R +\name{get_user_config} +\alias{get_user_config} +\title{Extrahiert Defaults aus User Config und ersetzt Werte} +\usage{ +get_user_config(config, params_to_check) +} +\arguments{ +\item{config}{Name der User Config} + +\item{params_to_check}{Vektor mit Parametern} +} +\description{ +Extrahiert Defaults aus User Config und ersetzt Werte +} +\keyword{internal} diff --git a/man/replace_by_parameter.Rd b/man/replace_by_parameter.Rd new file mode 100644 index 0000000..d2eae8d --- /dev/null +++ b/man/replace_by_parameter.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/user_config.R +\name{replace_by_parameter} +\alias{replace_by_parameter} +\title{Ersetzt Werte in aktiver Config mit gesetzten Parametern} +\usage{ +replace_by_parameter(yaml_file, parameter, config_param_name) +} +\arguments{ +\item{yaml_file}{Inhalt der aktiven Config} + +\item{parameter}{Wert des Parameters} + +\item{config_param_name}{Name des Parameters} +} +\description{ +Ersetzt Werte in aktiver Config mit gesetzten Parametern +} +\keyword{internal} diff --git a/tests/testthat/example_userconf/test b/tests/testthat/example_userconf/test index 95824e1..5d5cc4d 100644 --- a/tests/testthat/example_userconf/test +++ b/tests/testthat/example_userconf/test @@ -25,8 +25,9 @@ statR_prefix_phone: "Tel." statR_prefix_order_id: "Auftragsnr.:" # Default values -statR_index_title: Inhalt +statR_index_title: Auswertung statR_index_source: Statistisches Amt des Kantons Zürich +statR_index_toc_title: Inhalt statR_default_plot_width: 6 statR_default_plot_height: 3 diff --git a/tests/testthat/example_userconf/testone b/tests/testthat/example_userconf/testone index 2b5129c..20f4f3a 100644 --- a/tests/testthat/example_userconf/testone +++ b/tests/testthat/example_userconf/testone @@ -25,8 +25,9 @@ statR_prefix_phone: "Tel." statR_prefix_order_id: "Auftragsnr.:" # Default values -statR_index_title: Inhalt +statR_index_title: Auswertung statR_index_source: Statistisches Amt des Kantons Zürich +statR_index_toc_title: Inhalt statR_default_plot_width: 6 statR_default_plot_height: 3 diff --git a/vignettes/Benutzerkonfiguration.Rmd b/vignettes/Benutzerkonfiguration.Rmd new file mode 100644 index 0000000..c54d566 --- /dev/null +++ b/vignettes/Benutzerkonfiguration.Rmd @@ -0,0 +1,80 @@ +--- +title: "Benutzerkonfiguration" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Benutzerkonfiguration} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +## Allgemeine Informationen + +Die Benutzerkonfiguration erlaubt es, Informationen den Excel-Outputs mitzugeben. +Diese werden global gesetzt und jedes Excel-File enthält die selben Informationen. +Dies ermöglicht, Team-Spezifische oder Organisations-Spezifische Konfigurationen zu setzten. +Die Benutzerkonfiguration lebt nicht mehr im Package direkt, sondern es wird ein Pfad zur Konfiguration angegeben. +Der Grund für diese Auslagerung der Informationen ist, dass so ein ganzes Team auf die Gleiche Konfiguration zugreifen kann. +Falls keine eigene Konfiguration verwenet wird, fallen die Werte auf einen Default-Wert zurück, welche im Package hinterlegt sind. + + +## Erstellen einer eigenen Benutzerkonfiguration + +Die Benutzerkonfiguration wird in einem YAML-File gemacht. +Sie muss gleich sein wie das untenstehende Beispiel: + +```yaml +`r xfun::file_string(system.file("extdata/config/default.yaml", package = "statR"))` +``` + +Du hast die folgenden Konfigurations-Möglichkeiten: + +**contactdetails** + +In diesem Bereich kannst du die Kontakt-Informationen deines Teams oder der Organisation angeben. + +**logo** + +Hier kannst du die Angaben zum Logo machen, welches in den Excel-Files angezeigt werden soll. +Wenn du nicht das standard KTZH-Logo verwenden möchtest, musst du einen Pfad zu einem anderen Logo angeben. + +**prefixes** + +Hier kannst du bestimmte Schreibweisen definieren. +Dieser Teil ist vor allem dafür gedacht, dass eine andere Sprache konfiguriert werden kann. + +**defaults** + +Hier können bestimmte Default Settings gesetzt werden. +Unter anderem kannst du hier für das Index-Scheet (relevant bei datasets.xlsx) einen Titel sowie die Source definieren. +Zudem kannst du hier default Plot-Grössen definieren. +Diese Angaben könnten in den Funktionen auch überschrieben werden, wenn ein Plot dem Standard abweicht. + + +## Verwenden einer eigenen Benutzerkonfiguration + +Eine eigene Benutzerkonfiguration wird nicht automatisch im Package verwendet. +Wir müssem dem Package zuerst sagen, wo unsere Konfiguration liegt. + +Dazu gibt es ein paar Hilfsfunktionen: + +- Mit `addUserConfig()` kann eine neuer Konfiguration registriert werden. + +- Mit `updateUserConfig()` kann ein Pfad angepasst werden. + +- Mit `removeUserConfig()` kann eine Konfiguration entfernt werden. + + +Wenn du nun zum Beispiel eine Team-Konfiguration verwenden möchtest, dann kannst du wie folgt vorgehen: + +1. Kopiere die oben aufgeführten Angaben und passe sie für dich an + +2. Speichere das File als YAML ab (.yaml) + +3. registriere das neue Konfigurationsfile (hier als Beispiel für team_data): + + `addUserConfig(name = "team_data", path = "der_Pfad_zum_file")` + +4. wenn du eine Exce-Funktion aufrufst, setze den Parameter `config = "team_data"` + + +Du hast auch die möglichkeit mehrere Konfigurationen zu registrieren. Du kannst dann einfach mit dem `config`-Parameter bestimmen, welche Konfiguration angezogen werden soll. diff --git a/vignettes/Excel-Tabellen.Rmd b/vignettes/Excel-Tabellen.Rmd index aa4bcd3..e08e1b6 100644 --- a/vignettes/Excel-Tabellen.Rmd +++ b/vignettes/Excel-Tabellen.Rmd @@ -25,6 +25,7 @@ Das `statR` Package enthält Funktionen zur schnellen Erzeugung von Microsoft Ex Diese Vignette bietet einen Überblick der wichtigsten Funktionen in diesem Paket sowie einen Leitfaden zur Handhabung von Nutzerkonfigurationen. +Wichtig! Auch noch den Artikel der Benutzerkonfiguration lesen! ## Funktionen und Beispiele @@ -223,47 +224,6 @@ datasetsXLSX( ## Ausgewählte Themen -### Benutzerkonfigurationen -Um das Paket einem breiteren Anwenderkreis zugänglich zu machen, wurden diverse Textelemente im Design parametrisiert. Eingaben, die nicht NA sind, werden priorisiert. Werden Argumente zu Textelementen wie Kontaktinformationen aber bei NA belassen, werden Werte aus einer bestehenden und anpassbaren Nutzerkonfiguration substituiert. Das Paket kommt mit einer Standardkonfiguration ("default") mit dem folgendem Inhalt: - -```yaml -`r xfun::file_string(system.file("extdata/config/default.yaml", package = "statR"))` -``` -Basierend auf dieser Vorlage können auch weitere Konfigurationen erstellt werden. Anwendungsbeispiele: - -* Übersetzung von Textelementen in andere Sprachen -* Abteilungs-/Organisationsspezifische Kontaktinformationen - -Bei der ersten Verwendung von statR wird mit der Funktion `initUserConfigStore` ein Verzeichnis "~/.config/R/statR" angelegt und eine Index-Datei erstellt. In dieser Datei werden der Konfigurationsname und der Pfad zur Konfigurationsdatei gespeichert. - -Neue Konfigurationen müssen zunächst mit der Funktion `addUserConfig` registriert werden. Das folgende Beispiel demonstriert die Vorgehensweise: - -```{r, eval = FALSE} -# Laden der Konfiguration als Listenobjekt -new_config <- statR::readUserConfig("default") - -# Anpassung einzelner Eintraege -new_config$statR_config_name <- "team_data" -new_config$contactdetails$statR_name <- "Team Data" -new_config$logo$statR_logo <- "zh" - -# Speichern & Registrierung der neuen Konfiguration -yaml::write_yaml(new_config, "config/team_data.yaml") -statR::addUserConfig("team_data", "config/team_data.yaml") - -# Anwendung -mtcars_title <- "Motor trend car road tests" - -statR::quickXLSX(data = mtcars, - file = "output/userconfig_demo", - title = mtcars_title, - source = mtcars_source, - metadata = mtcars_metadata, - config = "team_data", - author = "Vorname Nachname") - -``` -Schliesslich besteht noch die Möglichkeit, Konfigurationen zu modifizieren (`updateUserConfig`) oder zu löschen (`removeUserConfig`). ### Einbindung von Bild-Dateien Bilder können gegenwärtig nur mit der `datasetsXLSX`-Funktion eingebunden werden. Die Bildgrösse muss vom Anwender über die Argumente `plot_width` und `plot_height` definiert werden. Die folgenden Modalitäten sind zu beachten:+ +/404.html ++ +/LICENSE.html ++ +/articles/Benutzerkonfiguration.html ++ +/articles/Excel-Tabellen.html ++ +/articles/Sonstige_Funktionen.html ++ +/articles/Visualisierungen.html ++ +/articles/html_report_template.html ++ +/articles/index.html ++ +/authors.html ++ +/index.html ++ +/news/index.html ++ +/reference/aXLSX.html ++ +/reference/addUserConfig.html ++ +/reference/add_attribute.html ++ +/reference/check_for_attributes.html ++ +/reference/datasetsXLSX.html ++ +/reference/display.html ++ +/reference/display.statcol.all.html ++ +/reference/excelIndexToRowCol.html ++ +/reference/extract_attribute.html ++ +/reference/flush_left.html ++ +/reference/index.html ++ +/reference/initUserConfigStore.html ++ +/reference/inputHelperContactInfo.html ++ +/reference/inputHelperHomepage.html ++ +/reference/insert_hyperlinks.html ++ +/reference/insert_index_hyperlinks.html ++ +/reference/insert_index_sheet.html ++ +/reference/insert_metadata_sheet.html ++ +/reference/insert_second_header.html ++ +/reference/insert_worksheet.html ++ +/reference/insert_worksheet_image.html ++ +/reference/interpolate2.html ++ +/reference/missingToNull.html ++ +/reference/namedRegionBoundary.html ++ +/reference/namedRegionExtent.html ++ +/reference/namedRegionExtent1D.html ++ +/reference/quickXLSX.html ++ +/reference/quick_sum.html ++ +/reference/readUserConfig.html ++ +/reference/readUserConfigStore.html ++ +/reference/removeUserConfig.html ++ +/reference/splitXLSX.html ++ +/reference/theme_stat.html ++ +/reference/updateUserConfig.html ++ +/reference/writeText.html ++ +/reference/zhpal.html +