Using R to work with data feeds

R is an open-source language for statistical analysis and data visualizations. Installing third party packages to your R environment provides functionality for connecting to data feeds.

For more information about R, see R: The R Project for Statistical Computing.

Sections in this article: 

Considerations and caveats

Who can do this

Igloo Authentication

When connecting to your digital workplace's data feeds, you must authenticate using your Igloo Authentication credentials. If you do not know what your Igloo Authentication password is, see Resetting a forgot Igloo password

R Libraries

The instructions in this article use:

  • httr package: Library for GET requests to data feeds URIs.
  • keyringr (Optional): Library for securely storing authentication credentials.
  • jsonlite: Libary for working with JSON data.

Connecting to your data feeds

  1. (Optional) Securely store authentication credentials with keyringr. Follow the keyringr instructions for your operating system.

  2. Within the R environment load the needed packages. 
    install.packages("keyringr")#if using keyringr
    library(keyringr)#if using keyringr
  3. Compose the URI of the GET request for the desired table.
    url <- "https://{your community domain}/odata/dUser"

    If using a filter, or URI that contains spaces, the character code of "%20" must be used in place of a space.

    url <- "https://{your community domain}/odata/dUser?$filter=user_key%20eq%2020322315"
  4. Get the data feeds.
    response <- GET(url, authenticate('{username}','{pass}'))
    df1 <- jsonlite::fromJSON(rawToChar((response$content))) 

    If using a secure method of password storage, substitute its function for '{pass}'.

Example: Importing two data feeds and merging them

  1. Install and load the libraries
    install.packages("keyringr")#if using keyringr
  2. Compose the URIs for the desired data feeds
    url1 <- "https://{your community domain}/odata/dContainerSpace" #odata url for space dimension table
    url2 <- "https://{your community domain}/odata/fContainerSpace" #odata url for space fact table
  3. Get the data feeds
    response1 <- GET(url1, authenticate('user', 'pass')) #load data for dimension table
    df1 <- jsonlite::fromJSON(rawToChar((response1$content))) #parse dimension data to dataframe
    response2 <- GET(url2, authenticate('user', 'pass')) #load data for fact table
    df2 <- jsonlite::fromJSON(rawToChar((response2$content))) #parse fact data to dataframe
  4. Merge the data feeds on their key
    merge(x=df1,y=df2,by.x=df1$space_key,by.y=df2$space_key) #join fact and dimension tables to get details for space level activity