2 Learning KoboToolBox and R
2.1 A quick tutorial on KoboToolbox
To get familiar with KoboToolBox, follow the steps below.
2.1.1 Building a simple form manually
- Sign in: https://kf.kobotoolbox.org/accounts/login/?next=/#/
- Click ‘New’ –> ‘Build from scratch’ –> Enter project name (‘test’) –> click ‘Create project’ (Sector and Country are compulsory: you can enter ‘Humanitarian - Food Security’ and ‘Zimbabwe’)
- Click ‘+’ –> click ‘Add question’ –> click ‘Text’ –> replace ‘New question’ by ‘Name of the head of the household’
- Click on ‘Setting’ (cog on the right side of the question box) –> click ‘Yes’ in ‘Mandatory response’
- Click on the lower ‘+’ sign –> click ‘Add question’ –> click ‘Number –> replace ’Enter a number’ by ‘Age of the head of the household’. Make the response mandatory.
- Add a validation criterion. Click on ‘Settings’ –> click on ‘Validation criteria’ (left part of the frame) –> make the criteria ‘Less than or equal to’ 100.
- Click on the lower ‘+’ sign –> click ‘Add question’ –> click ‘Select one’ –> replace ‘New question’ by ‘Did you grow maize during the last season?’ –> replace ‘Option 1’ by ‘Yes’ and ‘Option 2’ by ‘No’. Make the response mandatory.
- Click on the lower ‘+’ sign –> click ‘Add question’ –> click ‘Date’ –> replace ‘Enter a date’ by ‘Planting date’.
- Add a skip logic. Click on ‘Settings’ –> click on ‘Skip logic’ (left part of the frame) –> click on ‘Add a condition’ –> select ‘Did you grow maize during the last season?’ –> keep the logic ‘Yes’
- Click on the lower ‘+’ sign –> click ‘Add question’ –> click ‘Ranking’ –> replace ‘New question’ by ‘Reason to grow maize’ –> add a second choice –> Make 3 items to be ranked: food, income, and feed. Add the same skip logic as for ‘Planting date’ (only if the response to ‘Did you grow maize during the last season?’ is ‘Yes’
- Click on the lower ‘+’ sign –> click ‘Add question’ –> click ‘Point’
- Click on the lower ‘+’ sign –> click ‘Add question’ –> click ‘Acknowledge’ –> replace ‘Acknowledge’ by ‘Do you agree to be part of this survey?’. Drag this question so it becomes the first question.
- Click ‘Save’ (top right corner)
- Preview the form (eye icon, top left corner)
- Close the form. And deploy the form (if you don’t see the function to deploy, retrieve the test form in ‘Drafts’)
2.1.2 Filling forms on your android device
- Follow the steps here: https://support.kobotoolbox.org/data_collection_kobocollect.html
- Use this URL: https://kc.kobotoolbox.org, your user name and your password
- Go to ‘Get a Blank Form’, and get the form ‘test’
- Go to ‘Fill a Blank Form’, select your form, fill it up, and save
2.1.3 Visualizing and downloading the collected data on your computer
- Go to ‘Summary’. Check that your entry(ies) is(are) there.
- Go to ‘Data’. Inspect the data.
- Go to ‘Map’ (top left of the ‘Data’ tab, bottom of the menu)
- Go to ‘Download’ –> Click on ‘Export’ –> Click on ‘Download’ in the section ‘Exports’. You have your data ready for analysis!
2.1.5 Working with an XLSForm
- Click on ‘Form’ –> Click on ‘More action’ (‘…’) –> Click on ‘Download XLS’.
- Take a moment to study the content of the tab ‘survey’ and the tab ‘choices’. The tab ‘survey’ contains all your questions (in the order they appear in your form). The tab ‘choices’ contains all the factorial choices for your questions ‘Select one’
- Save the XLS Form as ‘test2.xls’
- Change the list name for the question ‘Did you grow maize last season’ into ‘maize’, in both the ‘survey’ and the ‘choices’ tabs.
- Change the list name for the question ‘Reason to grow maize’ into ‘reason’, in both the ‘survey’ and the ‘choices’ tabs.
- In the ‘survey’ tab, make all the answers as ‘required’ (except for geopoint) by changing ‘false’ into ‘true’
- In the ‘survey’ tab, column ‘name’, simplify variable names (be careful spaces are not allowed!) into: ‘Name’, ‘Age’, ‘Maize’, ‘Pdate’, ‘Reason’, ‘Reason_label’. Remember to make the same changes in the ‘relevant’ column (e.g., change ‘Did_you_grow_maize_during_the_’ to ‘Maize’)
- Create a question ‘Sex of the head of the household’ under the question ‘Name of the head of the household’. In the ‘survey’ tab, insert a row, enter ‘select_one sex’ in ‘type’, ‘Sex’ in ‘name’, ‘Sex of the head of the household’ in ‘label’, ‘true’ in ‘required’. In the ‘choices’ tab, insert two rows with ‘sex’ in ‘list_name’ for both, and ‘male’ – ‘Male’ for ‘name’ and ‘label’ for the first one, and ‘female’ - ‘Female’ for ‘name’ and ‘label’ for the second one.
- Save
- Go on your KoBoToolbox account and click on ‘New’
- Click on ‘Upload an XLSForm’
- Upload the file you created ‘test2.xls’
- Click on ‘Create project’ (keep the name ‘test2’)
- Preview the form. You can also go on ‘Edit’ (pencil icon) to see the changes that have been made to the form
2.1.6 Adding cascading questions
- Save ‘test2.xls’ as ‘test3.xls’.
- In the ‘survey’ tab, add three rows before the question ‘Name of the head of the household’
- In the first row, enter ‘select_one country’ (as type), ‘Country’ (as name), ‘Country’ (as label), ‘true’ (in required). Be careful with the designation of the list_name (no capital C) and the designations of the name and the label (capital C).
- In the second row, enter ‘select_one province’ (as type), ‘Province’ (as name), ‘Province’ (as label), ‘true’ (in required). Be careful with the designation of the list_name (no capital P) and the designations of the name and the label (capital P).
- In the third row, enter ‘select_one district’ (as type), ‘District’ (as name), ‘District’ (as label), ‘true’ (in required). Be careful with the designation of the list_name (no capital D) and the designations of the name and the label (capital D).
- Add a column ‘choice_filter’ (after the column ‘required’). In this column, enter
Country=${Country}for the row on Province, andProvince=${Province}for the row on District (nothing for the row on Country). - In the ‘choices’ tab, add two columns ‘Country’ and ‘Province’ (after label)
- Add 14 rows corresponding to the 2 countries (Zimbabwe, Zambia), the 4 provinces (Manicaland, Matebeleland, Southern, Northern) and the 8 districts (Chipinge, Nyanga, Hwange, Beitbridge, Mazabuka, Monze, Mbala, Senga). Enter the right list_name for each (country, province, district), names (with capital letters), and label (with capital letters). For Province names, enter the corresponding Country in the column ‘Country’ you created. For District names, enter the corresponding Province name in the column ‘Province’ you created.
- Save
- Go on your KoBoToolbox account and click on ‘New’
- Click on ‘Upload an XLSForm’
- Upload the file you created ‘test3.xls’
- Click on ‘Create project’ (keep the name ‘test3’)
- Preview the form. You can also go on ‘Edit’ (pencil icon) to see the changes that have been made to the form
2.1.7 An example of survey
Once you are familiar with the basics of KoboToolbox, you can analyse a more complex XLSForm.
The XLSForm used to build the survey questionnaire in KoboToolBox for the baseline survey of the CGIAR Agroecology Initiave in Zimbabwe can be found here: https://github.com/FBaudron/Supporting-codesign/blob/main/02-learning-kobo-r/BASELINE%20SURVEY%20TOOL.xlsx. The PDF of the questionnaire is also provided: https://github.com/FBaudron/Supporting-codesign/blob/main/02-learning-kobo-r/BASELINE%20SURVEY%20TOOL.pdf. Feel free to adapt this XLSform to your own use.
We will use a sample of the data generated from this questionnaire in the next chapter.
2.2 Resources to learn R
To work with R on your own computer, you need to download the program and install it, and install R-Studio Desktop, which is a separate program that makes R easier to use.
There are many free resources on the web to learn R: