Jonathan Munene Data Scientist Lead Consultant - SwissPeaks East Africa [R, Shiny, Tableau, XLSForms, Stata,SPSS, ODK, SurveyToGo, Data Science & Machine Learning].

Introduction to Data Science in R Part I

R is a powerful language used widely for data analysis and statistical computing. It was developed in early 90s. Since then, endless efforts have been made to improve R’s user interface. The journey of R language from a rudimentary text editor to interactive R Studio and more recently Jupyter Notebooks has engaged many data science communities across the world.

I have created the first part in a series of Introduction to Data Science in R, please click on this link Introduction to Data Science in R Part I

Generating Random Directional Steps in SurveyToGO

How to randomly select direction and steps to be followed during data collection. Incase you want to specify the direction and number of steps to be followed by your enumerators, the following guide will help you out.

Using text fields from a repeat group as choices in your XLSForm.

I want to know how many health facilities are within the respondents area/village and have a follow up question that asks of these facilities, which one is closer to the respondent.

XLSForms Authoring Tips and Tricks

Expert advice on how to author XLSForms.Have you ever wondered what a good XLSForm looks like, then this guide should help you author one of them

Improving performance of your XLSForm

Expert advice on how to improve performance on your XLSForms. You might be able to improve the performance of your form by altering some aspects of its design. To begin with, it's helpful to understand the two key reasons why users might encounter sluggishness when filling out a form.

Getting rid of the NaN in XLSForms calculations.

How to get rid of NaN in XLSForms Calculations. Sometimes its annoying when you want to display the value of calculation to the enumerator, but you get a NaN, this post will show you a workaround to this issue.

Generating Random Numbers in SurveyToGO

You might want to generate a random number from an array, and use it later in the survey. To do this, we’ll create a global var as follows;

var steps = RandomizeArray([20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50]);

The above will return a number between 20 and 50, selected randomly.

How to read all files in a folder and merge them into one file in R

If you have a folder with individual files and would like to merge them into one master file, you can use the following script.

#The required libraries
require(data.table)
require(readxl)

#Load the libraries
library(data.table)  
library(readxl)  

> We are using the package `readxl` because our files are Excel workbooks.

#Read the files (note this should be point to the folder where the files are located)
files <- list.files(path = "D:/Jmunene@Ona/xlsforms/Tz Water Points/data/57 LGAs PBR (August Update)",pattern = ".xls")
temp <- lapply(files, read_excel)

#Merge the files by rows. (Note: If the files don't have the same columns, the columns that don't match will be appended)
data <- rbindlist(temp ,fill = TRUE)

#Save the file, as a csv file - but you can choose the format you want :)
write.csv(data,file = 'Merged 57 LGAs PbR.csv',row.names = FALSE)