Protobi R library

Updated at October 28th, 2019

Protobi R library

Use Protobi R library to import/export data between R and Protobi.

Survey datasets are never final, there's always some cleaning, reshaping, additional variables, to create, etc. While much, or even all, of this can be done in the Protobi app itself, if R is your preferred language you may prefer to work in R.

This utility makes it easy to download data from Protobi as a dataframe, attach variable labels and value formats as titles and factors, and upload the revised dataframe back to Protobi.

Install the Protobi R library

You can install the protobi library directly from GitHub using devtools. At the R command prompt issue the following command:

# Install packages
install.packages("devtools")                    # Install devtools (once)
devtools::install_github("protobi/protobi-r")   # Install Protobi R Library (once)


Download data from Protobi

The library will download data from your project into an R data frame.  Options allow you to attach variable labels as titles and value formats as factors:

PROJECTID <- '5db09d115b989e00035ab0c7'  ## Unique identifier for project from URL
TABLEKEY <- 'processed'                  ## Identifier for data table from Data tab
APIKEY <- 'xxxxxxxx-xxxx-xxxx-xxxxxxxx'  ## See your Protobi account page for API key

data <- protobi_get_data(PROJECTID, TABLEKEY, APIKEY, formats=TRUE, titles=TRUE)

The PROJECTID identifies your project and can be found in the project URL.  

The TABLEKEY is the unique identifier for the data table and can be found in the Data tab under Project Settings.  

The APIKEY uniquely identifies you and authenticates you to the server.  Keep this secret!  You can get an API key under "My Account" within Protobi.  

Upload data to Protobi

To upload a dataframe to a Protobi project.  If a data table corresponding to TABLEKEY does not exist, it will be created. If not it will be updated in place.

protobi.put_data(data, PROJECTID, TABLEKEY, APIKEY)

Was this article helpful?