Exporting Kinduct Data with R-Studio

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:

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:

Open the script in R-Studio.

Locate the # Credentials parameters in the script.

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: