Nov 25, 2025
by
Muriithi Muriuki
This post was written by Muriuki, core member of the CARDT, a consultancy firm. Muriuki is a SurveyCTO user, R enthusiast and a MLE specialist.
A prerequisite to monitoring, evaluation, research, and learning (MERL) is collecting data in the field. One commonly used platform for this purpose is SurveyCTO, which specializes in mobile data collection in offline settings. This data is vital for making evidence-based decisions on what’s working (and should be scaled) and what needs more attention. Importantly, SurveyCTO’s REST API makes this data accessible for automated processing and analysis pipelines.
The R programming environment and its rich ecosystem of packages are well-suited for all sorts of MERL-related tasks, from data cleaning to statistical analyses to visualization. Many MERL professionals use R because it’s free and open-source, so it can be used by anyone, anywhere.
What has been missing is a simple way to interact with SurveyCTO data in R, which is why we developed the rsurveycto package.
The rsurveycto package allows R users to easily pull data from, and even push data to, a SurveyCTO server. The rsurveycto package relies on SurveyCTO’s REST API, but abstracts away the dreary details of dealing with API requests. To get a sense of what’s possible with R and SurveyCTO, let’s see the package in action.
First, we load the package and authenticate to a SurveyCTO server. I recommend creating a text file containing the server name, user name, and password — for our example, let’s name this text file “scto_auth.txt” (make sure the user is assigned a role that has permission to download data and for which “Allow server API access” is enabled). We also load the awesome data.table package, since rsurveycto makes heavy use of data.tables.
library('data.table')
library('rsurveycto')
auth = scto_auth('scto_auth.txt')
Next, let’s read data from a form.
form_submissions = scto_read(auth, 'my_form_id')
The scto_read() function understands the same options as the API, allowing you to specify a start date, a review status, and a private key for encrypted fields . You can retrieve server datasets in the same way, e.g., scto_read(auth, 'cases').
What if you want to know all the forms and datasets on the server? The rsurveycto package has you covered.
catalog = scto_catalog(auth)
In fact, you can read in all forms and datasets in one go.
forms_datasets = scto_read(auth)
Now the fun really begins. From here, you can use the power of R to wrangle the data, merge the data with data from other sources, fit statistical or predictive models, and make elegant and informative plots.
But wait, there’s more! The rsurveycto package can also fetch detailed metadata and form definitions, download file attachments, and even write to an existing server dataset. Best of all in my opinion, the package is free, open-source, and available on CRAN.
I hope the package is useful in R-based data processing, analysis, and visualization pipelines involving SurveyCTO data. Please try it.be
Join our newsletter to sta and provide con