---
title: "Draft report"
vignette: >
  %\VignetteIndexEntry{Draft report}
  %\VignetteEngine{quarto::html}
  %\VignetteEncoding{UTF-8}
---

After all the data has been washed, the chapter overview has been created, and any adjustments to the templates in `02_resources` have been made, we can finally create a draft report!

1. It is natural to set up an RStudio Project (\*.Rproj) for the Saros folder that remembers unsaved R files, some personal preferences for the project, etc. But avoid saving the working memory (Environment) to disk (.Rdata) , so that functionality can be turned off in Project options... The reason is that over time there can be many large objects, and as much as possible should be able to be run from scratch when you need it.

2. Given that everything is set up correctly, there are really only 2-3 syntax files you will need to work with each implementation.
    0.  `000_initialize_project.R`: Establishes global paths, and lists to be populated with datasets, etc for each year. The system is set up so that you can easily handle several years (implementations) without accidentally overwriting each other. You are actually guaranteed that the spring of 2024 will always be the spring of 2024 when you loop over several years - given that the data sets are stored in the correct folders.
    1.  `001_configure_report.R`: This file is, in a way, the main file from which you control most things. From this, you can select a cohort/implementation you want to run, or loop over several at the same time (even several respondent groups, such as in the Participant surveys). The first loop is meant to be run to generate drafts. Further down are ready-made scripts to compile the web pages/PDF files, as well as generate access protection and issue password access to institutions.
    2.  `002_specify_report_cycle_params_for_{CYCLE}.R`: Little used so far. Used as storage of year-specific information that can be used to fill in the report's fixed points, such as report number, the survey's opening period, etc.
    3. `003_get_report_cycle_paths.R`: Here you should rarely need to change anything, as long as there are no odd exceptions a year.
    4. `200_prep_data_for_{CYCLE}.R`: You can choose whether you want to do all washing of post-data collection data outside the Saros process, or inside.
        1.  If you want to do all the data washing before Saros is involved (for example, that it is done by a Stata user), you should still keep this R script to read in the actual variable labels from the raw data again, as Stata and SPSS cut off variables - labels. In addition, you discover a number of things when you are running saros, which are easiest to fix in this script. Typically this applies to variable labels and similar "aesthetics".

        2.  If you want to do everything in the Saros process, it may be natural to divide the data preparation into several scripts and put in a subfolder for the given year/implementation so that you keep order (must then update in the get_paths script).

        *Irrespective of which direction, the possibility should be kept open that, during implementation, it can be switched between the two, for increased robustness. Also, it is important to save the data sets between each step for documentation, practical considerations (a chapter author wants all the data, etc).*
    5. `draft_saros_reports.R`: Here the chapter overview and settings in `_report_generation_setup.yaml` are obtained (which can be overridden for a specific implementation, or for just the mesos reports).
    6. `render_and_publish.R`: In this script everything is moved from the folder with finished drafts to a temporary folder (temp). The latter folder should not be located on OneDrive/cloud solution/Sharepoint as there are many files that are copied and created which run slowly when OneDrive has to synchronize along the way. BUT MORE IMPORTANTLY, SHAREPOINT HAS A LIMITATION ON THE NUMBER OF CHARACTERS IN THE PATHS WHICH CAUSES FILES SUDDENLY NOT TO BE FOUND AND GIVES WEIRD ERROR MESSAGES.
    7. `email_credentials.R`: This is for mesos reports only. With an overview of e-mail information for contact persons at the institutions who will each have their own report, they can be sent usernames/passwords. Set `send_emails <- FALSE` to only create drafts in your Outlook folder for this. Set as `TRUE' to actually send out immediately (does not affect any drafts you may have already created in your Outlook folder).