id id_string
1 411456 a58ZhjX6M8WXtzLGvBaEaG
2 740625 a8HyzdxnVjK53dt4fX3Vup
3 331453 aae4wz2tpkSnAkea2PAzin
4 363465 abYGMsrMvkGsnA4xm9kqC9
5 363431 acCBJaRqBkSMPYdvaaWCSu
6 334099 ad3NtS6TDPuKTUKCAyCuby
7 363349 aEMERWLYQAdhaMKMt5QkD7
8 307736 aeMJQLo56HWyVHkKX9oaJD
9 740631 ahYJ7XRUcit8gbFYwaxnAV
10 1151489 aLqdPLTCZb8jvFkDxcFwzy
11 1136694 aMteoHisncRUStdyZfsjMB
12 740623 aoLcmmN8KWG4N6A3XpUiRT
13 740628 aRJW7SwKsVyZu8b4FighiM
14 363466 asv7tL6CEYjiW2XCkLxhcX
15 411469 aswcEAtxj24u9MfuBmS9AW
16 740630 aThMD6zuEFjtTfptwcpZPg
17 411388 aTyGBYk6HvRXmki9ksb29p
18 740624 aUeYzPfq6WED4dDF28VT9D
19 363381 aWd7wujF5d5HYaYMhT4jBZ
20 740626 awMnFDna5kWR3LXKyGmFMd
21 331848 axYbEbLcJxzUNFbqMVySjJ
22 740629 axyJSgLRDeSk3BHB6cJmYk
23 408149 ayhCy68ZTaDGc7tuGthQpJ
24 740627 aYokcZAjTZ9JCyVXz4R5rh
title
1 PLAY Home Questionaires - 12 Bilingual English (2020-03-04)
2 PLAY_HomeQuestionaires_12_English
3 PLAY Home Questionnaires (24 English)
4 PLAY Home Questionnaires - 24 Bilingual English (2020-03-04)
5 PLAY Home Questionnaires - 12 English (2020-03-04)
6 PLAY Home Questionnaires (12 Bilingual - English)
7 PLAY Home Questionnaires - 18 English (2020-03-04)
8 PLAY Home Questionnaires (18 English)
9 PLAY_HomeQuestionaires_24_Bilingual_English
10 Clone of Clone of PLAY_HomeQuestionnaires_18_English - NO AUTO METADATA
11 Clone of PLAY_HomeQuestionnaires_18_English - NO AUTO TODAY
12 PLAY_HomeQuestionaires_12_Bilingual_English
13 PLAY_HomeQuestionnaires_18_English
14 PLAY Home Questionnaires - 18 Bilingual English (2020-03-04)
15 PLAY Home Questionnaires - 12 Bilingual Spanish (2020-03-04)
16 PLAY_HomeQuestionaires_24_Bilingual_Spanish
17 PLAY Home Questionnaires - 18 Bilingual Spanish (2020-03-04)
18 PLAY_HomeQuestionaires_12_Bilingual_Spanish
19 PLAY Home Questionnaires - 24 English (2020-03-04)
20 PLAY_HomeQuestionaires_18_Bilingual_English
21 PLAY Home Questionnaires (12 English)
22 PLAY_HomeQuestionnaires_24_English
23 PLAY Home Questionnaires - 24 Bilingual Spanish (2020-03-04)
24 PLAY_HomeQuestionaires_18_Bilingual_Spanish
description
1 PLAY Home Questionaires - 12 Bilingual (English) (2020-03-04)
2 PLAY_HomeQuestionaires_12_English-2021-07-29
3 PLAY Home Questionnaires (24 English)
4 PLAY Home Questionnaires - 24 Bilingual English (2019-11-20)
5 PLAY Home Questionnaires - 12 English (2019-11-20)
6 PLAY Home Questionnaires (12 Bilingual - English)
7 PLAY Home Questionnaires - 18 English (2018-11-20)
8 PLAY Home Questionnaires (18 English)
9 PLAY_HomeQuestionaires_24_Bilingual_English-2021-07-30
10 Clone of Clone of PLAY_HomeQuestionnaires_18_English - NO AUTO METADATA
11 Clone of PLAY_HomeQuestionnaires_18_English
12 PLAY_HomeQuestionaires_12_Bilingual_English-2021-07-29
13 PLAY_HomeQuestionnaires_18_English-2021-07-29
14 PLAY Home Questionnaires - 18 Bilingual English (2019-11-20)
15 PLAY Home Questionnaires - 12 Bilingual Spanish (2020-03-04)
16 PLAY_HomeQuestionaires_24_Bilingual_Spanish-2021-07-30
17 PLAY Home Questionnaires - 18 Bilingual Spanish (2020-03-04)
18 PLAY_HomeQuestionaires_12_Bilingual_Spanish-2021-07-29
19 PLAY Home Questionnaires - 24 English (2019-11-20)
20 PLAY_HomeQuestionaires_18_Bilingual_English-2021-07-29
21 PLAY Home Questionnaires (12 English)
22 PLAY_HomeQuestionnaires_24_English-2021-07-30
23 PLAY Home Questionnaires - 24 Bilingual Spanish (2020-02-27)
24 PLAY_HomeQuestionaires_18_Bilingual_Spanish-2021-07-29
url
1 https://kc.kobotoolbox.org/api/v1/data/411456
2 https://kc.kobotoolbox.org/api/v1/data/740625
3 https://kc.kobotoolbox.org/api/v1/data/331453
4 https://kc.kobotoolbox.org/api/v1/data/363465
5 https://kc.kobotoolbox.org/api/v1/data/363431
6 https://kc.kobotoolbox.org/api/v1/data/334099
7 https://kc.kobotoolbox.org/api/v1/data/363349
8 https://kc.kobotoolbox.org/api/v1/data/307736
9 https://kc.kobotoolbox.org/api/v1/data/740631
10 https://kc.kobotoolbox.org/api/v1/data/1151489
11 https://kc.kobotoolbox.org/api/v1/data/1136694
12 https://kc.kobotoolbox.org/api/v1/data/740623
13 https://kc.kobotoolbox.org/api/v1/data/740628
14 https://kc.kobotoolbox.org/api/v1/data/363466
15 https://kc.kobotoolbox.org/api/v1/data/411469
16 https://kc.kobotoolbox.org/api/v1/data/740630
17 https://kc.kobotoolbox.org/api/v1/data/411388
18 https://kc.kobotoolbox.org/api/v1/data/740624
19 https://kc.kobotoolbox.org/api/v1/data/363381
20 https://kc.kobotoolbox.org/api/v1/data/740626
21 https://kc.kobotoolbox.org/api/v1/data/331848
22 https://kc.kobotoolbox.org/api/v1/data/740629
23 https://kc.kobotoolbox.org/api/v1/data/408149
24 https://kc.kobotoolbox.org/api/v1/data/740627
form_url
1 https://kf.kobotoolbox.org/api/v2/assets/a58ZhjX6M8WXtzLGvBaEaG.xls
2 https://kf.kobotoolbox.org/api/v2/assets/a8HyzdxnVjK53dt4fX3Vup.xls
3 https://kf.kobotoolbox.org/api/v2/assets/aae4wz2tpkSnAkea2PAzin.xls
4 https://kf.kobotoolbox.org/api/v2/assets/abYGMsrMvkGsnA4xm9kqC9.xls
5 https://kf.kobotoolbox.org/api/v2/assets/acCBJaRqBkSMPYdvaaWCSu.xls
6 https://kf.kobotoolbox.org/api/v2/assets/ad3NtS6TDPuKTUKCAyCuby.xls
7 https://kf.kobotoolbox.org/api/v2/assets/aEMERWLYQAdhaMKMt5QkD7.xls
8 https://kf.kobotoolbox.org/api/v2/assets/aeMJQLo56HWyVHkKX9oaJD.xls
9 https://kf.kobotoolbox.org/api/v2/assets/ahYJ7XRUcit8gbFYwaxnAV.xls
10 https://kf.kobotoolbox.org/api/v2/assets/aLqdPLTCZb8jvFkDxcFwzy.xls
11 https://kf.kobotoolbox.org/api/v2/assets/aMteoHisncRUStdyZfsjMB.xls
12 https://kf.kobotoolbox.org/api/v2/assets/aoLcmmN8KWG4N6A3XpUiRT.xls
13 https://kf.kobotoolbox.org/api/v2/assets/aRJW7SwKsVyZu8b4FighiM.xls
14 https://kf.kobotoolbox.org/api/v2/assets/asv7tL6CEYjiW2XCkLxhcX.xls
15 https://kf.kobotoolbox.org/api/v2/assets/aswcEAtxj24u9MfuBmS9AW.xls
16 https://kf.kobotoolbox.org/api/v2/assets/aThMD6zuEFjtTfptwcpZPg.xls
17 https://kf.kobotoolbox.org/api/v2/assets/aTyGBYk6HvRXmki9ksb29p.xls
18 https://kf.kobotoolbox.org/api/v2/assets/aUeYzPfq6WED4dDF28VT9D.xls
19 https://kf.kobotoolbox.org/api/v2/assets/aWd7wujF5d5HYaYMhT4jBZ.xls
20 https://kf.kobotoolbox.org/api/v2/assets/awMnFDna5kWR3LXKyGmFMd.xls
21 https://kf.kobotoolbox.org/api/v2/assets/axYbEbLcJxzUNFbqMVySjJ.xls
22 https://kf.kobotoolbox.org/api/v2/assets/axyJSgLRDeSk3BHB6cJmYk.xls
23 https://kf.kobotoolbox.org/api/v2/assets/ayhCy68ZTaDGc7tuGthQpJ.xls
24 https://kf.kobotoolbox.org/api/v2/assets/aYokcZAjTZ9JCyVXz4R5rh.xls
There are n= {r dim(kb_home_df)[1]} separate data files.
Retrieve and save files
We save the answer files in data/xlsx/home_visit/raw/ans and the question files in data/xlsx/home_visit/raw/qs. To extract the answer data only, we would set save_form = FALSE.
Note
This process seems inefficient. Most of the time most of the files do not change. But, it ensures that if there are any upstream changes to the raw KoBoToolbox data forms that those get propagated to our local copies.
Next we import a CSV for a given form year, age group, and language group, and create two new CSV files: one with the MB-CDI data and one with all of the other survey questions.
By default, the document presumes that we want to convert all of the CSV files
Extract the ‘non-mbcdi’ questions first and add ‘non_mbcdi’ to the filename.
# Gather## AboutThis page gathers KoBoToolbox files from the home visit questionnaires.## SetupLoad helper functions and required package dependencies.```{r setup}fl <- list.files( file.path(here::here(), "R"), "^load|^kobo_|^file_|^screen_|^ecbq_|^health_|^databrary|^home|^make|^export|^post_visit|CONSTANTS", full.names = TRUE )purrr::walk(fl, source)suppressPackageStartupMessages(library(tidyverse))```Data files for each of the language by age-group conditions are stored on KoBoToolbox (KBT).The data files on KBT are stored in `kb_df`, a data frame that is generated as one of the workflow targets.```{r home-visit-list-forms}targets::tar_load(kb_df, store=file.path(here::here(), "_targets"))kb_df```## Download data {-}List data forms specific to the home visit by filtering the files with names that contain "Home".```{r filter-home-visits}kb_home_df <- kobo_list_data_filtered(kb_df, "Home")kb_home_df```There are *n*= {r dim(kb_home_df)[1]} separate data files.## Retrieve and save files {-}We save the answer files in `data/xlsx/home_visit/raw/ans` and the question files in `data/xlsx/home_visit/raw/qs`.To extract the answer data only, we would set `save_form = FALSE`.::: {.callout-note}This process seems inefficient.Most of the time most of the files do not change.But, it ensures that if there are any upstream changes to the raw KoBoToolbox data forms that those get propagated to our local copies.:::```{r retrieve-home-xlsx-from-kobo}kobo_retrieve_save_many_xlsx( kb_home_df, save_dir = file.path(here::here(), "data/xlsx/home_visit/raw"), save_form = TRUE)```### Normalize file names {-}Some of the form names are inconsistent, so we normalize them to fit the following pattern:`<form_id>_PLAY_HomeQuestionnaires_<age_group>_<lang_group>.xlsx````{r rename-home-visit}rename_home_xlsx( fl = list.files( file.path(here::here(), "data/xlsx/home_visit/raw/ans"), "\\.xlsx$", full.names = TRUE ), out_dir = file.path(here::here(), "data/xlsx/home_visit/std_name"))```### Save renamed xlsx as csv {-}We save the (answer) CSVs in `data/csv/home_visit/raw`.```{r load-xlsx-save-csvs}file_load_xlsx_save_many_csv( in_dir = file.path(here::here(), "data/xlsx/home_visit/std_name"), out_dir = file.path(here::here(), "data/csv/home_visit/raw"), filter_str = ".*")```## Split MB-CDI from non {-}Next we import a CSV for a given form year, age group, and language group, and create two new CSV files: one with the MB-CDI data and one with all of the other survey questions.By default, the document presumes that we want to convert **all** of the CSV filesExtract the 'non-mbcdi' questions first and add 'non_mbcdi' to the filename.```{r split-non-mbcdi}file_split_non_mbcdi_csvs( fl = list.files( file.path(here::here(), "data/csv/home_visit/raw"), "\\.csv$", full.names = TRUE ), out_dir = file.path(here::here(), "data/csv/home_visit/non_mbcdi/raw"))```Creating a separate MBCDI CSV relies on a very similar function `file_split_mbcdi_csvs`.```{r split-mbcdi}file_split_mbcdi_csvs( fl = list.files( file.path(here::here(), "data/csv/home_visit/raw"), "\\.csv$", full.names = TRUE ), out_dir = file.path(here::here(), "data/csv/home_visit/mbcdi"))```