After users have the necessary datasets in the correct folders, user can run create_report.R to generate the report. This page walks through how to modify the code so that everything runs properly. There are two places in the code that the user needs to change manually.

  1. Starting line 24 to manually change certain section name. (optional)
  2. Line 29 to indicate which modules are individual-level interviews. (required)

We will go through the code in more details below and show where user inputs are needed in red.

# =============================================================================
# Create report (LSMS Paradata Tool - Module Stats)
# =============================================================================

# -----------------------------------------------------------------------------
# 1) Data Preparations
# -----------------------------------------------------------------------------

# load packages and functions
source("R/0_load_requirements.R")

The code above runs 0_load_requirement.R, an R-code script in the R folder. If you are running this code for the first time, the wait time might be longer because the code install all packages that is needed to run all the remaining codes. Afterwards, running this code will be faster.

# prepare paradata
source("R/0_extract_and_clean_paradata1.R")

# Run the line below to see a list of all section names. 
print(unique(data$section[!is.na(data$section)])) 

After running the code above, in your console, you should see a list of all modules available in the paradata.

# -----------------------------------------------------------------------------
# 2) User Inputs
# -----------------------------------------------------------------------------

### Manually Change Sections Names if Necessary using the Code Below 

data[section=="Old Name", section:="New Name"] # Old Name will be changed to New Name
data[section=="Cover", section:="01. Cover"]   # Cover will be changed to 01. Cover

(1) Input needed - optional. If there is a module name that is too long or if the users would like to combine modules, change the name of the section manually above. Change “Old name” into, “New Name”. You can keep the code above without deleting it. All it will do is find modules with the value “Old Name” and then change it. It will not change anything as long as this value isn’t in the data.

### Identify which ones are individual modules. Modify the list below. Separate with a comma. 

ind_modules <- c("11a. Availability for the individual interview","12. Education and Literacy", 
                 "13. Health care seeking & expenditure", "14a. Internal Migration of Household Members", 
                 "14b. International Migration of Household Members", 
                 "15. Employment", "16. Time Use", "17. Individual - level parcel details", 
                 "18. Apartment", "19. Livestock ownership", "20. Consumer Durables", "21. Mobiles", 
                 "22. Financial assets")

(2) Input needed - REQUIRED. Based on the modules/sections name you have above, you need to tell the code, which one are individual-level modules vs household-level modules. This is needed so that the code can calculate interview time by person instead of by household for individual modules. Change the code based on the list of modules you observed after running source(“R/0_extract_and_clean_paradata1.R”) and put the individual modules into the code above. Please keep the same coding syntax as above.

### Specify List of Responsible per Team 

# Here is the team list: 
unique(data$responsible)

# Please put csv sheet containing enumerator login (related to variable responsible) and supervisor.
# Run the code below to upload the data. 

teams <- readr::read_csv("data/03_microdata/team_list.csv")

# After modifying the above code, continue running the code below. 
source("R/0_extract_and_clean_paradata2.R")

The code above exports the list of interviewer and teams. In source(“R/0_extract_and_clean_paradata2.R”), teams will be created based on the list and person ID is also created. It will then save the final clean paradata file in data/04_created/paradata_clea.csv.

# -----------------------------------------------------------------------------
# 3) Output Report
# -----------------------------------------------------------------------------

quarto::quarto_render(input = "R/Paradata_Report.qmd")

# Delete previous file is exist. 
if (file.exists("data/04_created/Paradata_Report.html")) {
  file.remove("data/04_created/Paradata_Report.html")
}

# Move new file into folder. 
fs::file_move(
    path = "R/Paradata_Report.html",
    new_path = "data/04_created/Paradata_Report.html"
)

# Your report is ready in the new path specified. 

The final piece of code above creates the report and you should be all set. The report is in data/04_created/Paradata_Report.html. The html report can be emailed or copied and it will retain all its information and interactivity.