Everything you need to know about using the Kinduct Platform

Exporting Kinduct Data with R-Studio

Print Friendly and PDF

Kinduct has created a script that allows you to export all data from your Kinduct site into a user-friendly data table formatted with rows and columns. This script also includes code that allows you to customize which data is exported to the data table. This integration allows for secure transfer of Kinduct data to user environments – leveraging and providing information in a standard data table format.

With this script, you can:

  • Retrieve data from Kinduct and filter data for interested fields, dates, or individuals. The data is transferred into a format ready for analysis.
  • Configure to automate data pulls and write to CSV format as a source for other reporting or analysis tools.
  • Automate a script that adds in-house proprietary calculations on top of Kinduct data by combining exporting and importing scripts around analyst-built functions.

Additional configuration to your platform is not required to use the script since the current Kinduct API is used. However,  before you can use the script you will need:

  • Kinduct API credentials:  Contact your CSM to obtain your site-specific “CLIENT ID” key ,“CLIENT SECRET” key, and Client Name.
  • Installation of R (version 3.0.0 or greater) and/or R-Studio (version 0.99.902 or greater) on your computer with the ability to install packages in the R environment.
  • Internet access.

 NOTE: Advanced knowledge of R-Studio is not required to run the script; however, some basic tasks in R-Studio must be completed to implement the script.

Setting Up the Script

Before you can use the script to export data from your Kinduct site, the following tasks must be performed in R-Studio:

  • Install the required packages.
  • Download and add the Kinduct-provided script to your environment.
  • Configure the script with your site-specific information.

Installing Packages

If you are using R-Studio for the first time, you need to ensure that these packages are installed for the script to run:

  • jsonlite
  • httr
  • data.table

To install the packages:

  1. Open R-Studio
  2. Click the Packages tab.
  3. Click Install. The Install Packages dialog displays:

  4. Type the name in the Packages field to search (e.g. jsonlite). The package name should auto-complete as you start to type, select from the list and click Install.

NOTE: The installation of these packages only needs to be done once. The script will load them each time it is run.

Adding Script to R-Studio

 Once the Kinduct Data Export Script file (.rtf format) is downloaded to your computer:

  1. Open a blank R-Studio screen.
  2. Copy the contents of the .rtf script file and paste to R-Studio.
  3. Save the script in R-Studio.

The script can now be configured and customized in R-Studio.

NOTE: Saving a copy of the script in .rtf format to your computer is recommended in case you need to revert to the default script at any time.

Configuring the Script

The provided script needs to be configured with API credentials that are site-specific. You must obtain your Client Name,  Client Secret key, and Client ID key from your CSM if you want to use the script.

To configure the script:

  1. Open the script in R-Studio.
  2. Locate the # Credentials parameters in the script.
  3. Enter your client_secret key, client_id key, and clientname that were provided to you.


Customizing the Script

Query Dates

The script is essentially ready to run as-is with the exception of the query dates. The start date and end date for the data queried needs to be modified for the desired timeframe each time the script is run.


With more advanced R-Studio knowledge, you can configure the query date parameters to be more of a dynamic process; for example, using the Sys.Date()-1 function  will query all data for the previous day.

Data Filters

The script contains lines of code that allow you to further customize the data that will be exported. This code is commented-out by default and is found under the ## optional filter rows. You can use this code to filter data by rows.

The example below has the code configured to only export all data with “Andrei” in the first name column; however, this code can be modified to filter any data you wish (e.g. fatigue above 5). There are endless options with what you can filter into your table, the code is there for you to modify as you need.

To customize the data that is exported to the table by row, remove the hashtag in both lines under ## optional filter rows, enter the desired filter criteria and then run the script.


The script also includes base code under ## optional filter columns for you to filter data by column. Note that there are three lines of code under this section; therefore, hashtags must be removed from all three lines for the script to run correctly when using this filter option.


File Export

The script includes functions for defining the working directory (setwd) and filename (write.csv). In the example below, “api export” is set as the working directory and “export.csv” is the filename for the Kinduct export data table.  These parameters are also customizable for your environment.


Running the Script

Once the script is configured and/or customized, it is ready to run (also called “sourcing” the script).
To run the script from Mac OS:

  • Using R, do one of the following:
    1. Click anywhere in your script and press Command + E.
    2. Click Edit ⟶ Source Document.
  • Using R-Studio, do one of the following:
    1. Click the “Source” button.
    2. Press Command + Shift + S.
    3. Click Code ⟶ Source.

To run the script from Windows:

  • Using R :
    • Choose Edit ⟶ Run all
  • Using R-Studio, do one of the following:
    1. Click anywhere in the source window and press Ctrl + Shift + S / Ctrl + Shift + Enter.
    2. Click the “Source” button.

Video Tutorial

Video walkthrough tutorial of export code:

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Please sign in to leave a comment.