saros: Semi-Automatic Reporting of Ordinary Surveys

Introduction

{saros} (Semi-Automatic Reporting of Ordinary Surveys) is an R package designed to handle repeating surveys within the same project that occur annually or biannually. It aims to automate the process of summarizing and reporting on survey data, helping researchers save time and maintain consistency across survey iterations. Specifically, {saros} produces highly customizable figures, tables, analyses and complex interactive reports for a batch of possible dependent-independent relations of possible interest.

Overview: tools for five stages of the report production

What Note Sub-package
Project setup containing ready-made R-scripts and folders Optional saros.base
Data cleaning Only supplements {tidyverse}/{datawizard}/ {labelled}-tools saros.utils (not on CRAN)
Report drafting saros.base
Easy content generation for common standardized outputs Standardized output types. Alternatively use your own functions saros
Web access restriction and distribution Optional saros.base

Why saros?

Workflow

Preliminaries:

  1. Optionally set up your project directory for a completely new project.
  2. Clean your raw data: - Variables should be stored in the data type that they should be displayed as (factor, ordered factor, integer, character, etc). Ordered factors will in certain outputs be kept in the given order, whereas a set of unordered factors may be e.g. sorted_by = ".upper" (e.g values of the upper-most categories). - Variables should have variable labels, and sets of variables should have the same variable label prefix. Prefix and suffix can be split by e.g ” - “. Use e.g. {labelled} for most operations. For advanced cleaning, see saros.utils

{saros}-tools

{saros.base}-tools

  1. Optionally specify chunk templates for what you want for each set of related variables. Or use among the built-in sets of templates.
  2. Optionally, create a chapter_overview (a compact description of which dependent (and independent) variables goes in which chapter-file). A data.frame where a row is a chapter. Must contain at least the columns ‘chapter’ and ‘dep’. ‘dep’ uses tidyselect-syntax in each cell. If not using any, all variables are processed and placed in the same qmd-file. More details
  3. Combine the raw data, chunk templates and chapter_overview to make a chapter structure. This will create a data frame containing your report structure, which can be further tailored. Arguments to refine_chapter_overview() allows e.g ignoring:
    • non-significant bivariate relationships between dependent and independent variables,
    • low observation counts (sample size) for categories, variables or dependent-independent cell combinations, and/or
    • variables with all NA for a given “crowd” (a target group, all others combined, or all)
  4. Draft the report, using the output from refine_chapter_overview() and your raw data. Optionally provide a range of YAML-defaults and QMD-prefixes/suffixes to your chapter-files, index-files or full report-files, as well as creating chapter-datasets for compartmentalized authoring.
  5. After rendering your Quarto Project (using regular Quarto/RStudio tools), optionally batch configure access restrictions and send out glue-tailored emails to institutions that have participated in your survey, now receiving password-protected access to their own report.
  6. Having done this once for a report, you might want to create a project template for your organization. Folder structures can be mapped to a YAML file so that it can later be easily created at once with your preferred directory numbering scheme. If located on e.g. GitHub this can be downloaded, unzipped and placed in a new project folder.

Installation

The development version from GitHub with:

install.packages("pak")
pak::pak("saros")
# # pak::pak("NIFU-NO/saros")
install.packages("saros", repos = c('https://nifu-no.r-universe.dev', 'https://cloud.r-project.org')) # Alternatively, latest developer-version at GitHub

Draft a simple report using defaults, in a temporary folder

library(saros)
refine_chapter_overview(data = ex_survey,
                        chapter_overview = ex_survey_ch_overview) |>
  draft_report(data = ex_survey)

Draft a customized report

library(saros)
refine_chapter_overview(data = ex_survey,
                        chapter_overview = ex_survey_ch_overview,
                        chunk_templates = get_chunk_template_defaults(2),
                        always_show_bi_for_indep = "x1_sex",
                        hide_bi_entry_if_sig_above = .05) |>
  draft_report(data = ex_survey,
               prefix_heading_for_group = c(".variable_name_indep" = "---\n"),
               serialized_format = "qs" # qs-format, if installed, is faster than rds
               )

Draft a customized report, one for each participating university

---
params:
    mesos_var: "f_uni"
    mesos_group: "Uni of A" # This can be replaced in a command: `quarto render ch1.qmd -P mesos_group:'Uni of A'`
---
library(saros)
refine_chapter_overview(data = ex_survey,
                        chapter_overview = ex_survey_ch_overview,
                        chunk_templates = get_chunk_template_defaults(2),
                        always_show_bi_for_indep = "x1_sex",
                        hide_bi_entry_if_sig_above = .05) |>
  draft_report(data = ex_survey,
               prefix_heading_for_group = c(".variable_name_indep" = "---\n"),
               auxiliary_variables = "f_uni",
               serialized_format = "qs"
               )

IMPORTANT: saros is free, except in Norway

Outside of Norway, this package can be used in accordance with the MIT license. However, persons affiliated with Norwegian non-profit or profit/commercial organizations must have the explicit written permission from the author for use. Simply put, if your department/organization competes with NIFU on commissioned or open research calls within Norway, you are probably not going to get permission unfortunately.

Acknowledgements

Code of Conduct

Please note that the saros project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.