Using the Displayr Cloud Drive R API

From Displayr
Jump to: navigation, search

The Displayr Cloud Drive offers a way for licensed users to store and share files across your company documents. While there are various built-in ways to import and export these shared files, it is also possible to use R code by going to the Data Sets tree and clicking either + or + Add a Data Set or by creating a Calculation > Custom Code. This allows you to load and save R data sets (.rds) and .csv files using a series of R functions from the flipAPI package.

Sharing files with flipAPI

To check whether a file exists within the Cloud Drive, you can use the QFileExists function by simply specifying the name and extension of the file in question:


This will return a TRUE or FALSE.

To load an existing file stored in the Cloud Drive, QLoadData should be used with the exact name and extension of the file:


If you have multiple companies under the same account, you can share files among your companies using the company secret key where the file is located (this can be provided on request):


Similarly, to save a file, you should use QSaveData by passing the name of the output and then specifying the name and extension of the file:


When working with csv files, QFileOpen is a further function for reading and writing data. The below code opens the specified csv file as read only and loads it into your R Output:

con = QFileOpen('temp.csv', open='r')

A second example shows how to write data to a csv file using this function:

con = QFileOpen('temp.csv', open='w')

Here, temp.csv is created, the contents of data are written to it and it is then saved to the Cloud Drive.

See the R documentation for QFileExists, QLoadData, QSaveData, QOpenFile for more details.