Advanced Initialization of RStudio

2024-04-17

Premium Feature — This feature supports RStudio, which is part of the Professional Plus and Enterprise Editions. Learn more or contact LabKey for details.

This topic describes the process for initializing RStudio to enable the viewing of the LabKey schema within the RStudio or RStudio Pro workspace. By default this option is enabled.

Note: To use this feature, you must have the latest version of Rlabkey.

Configuration

Follow the steps for configuring LabKey to access your RStudio or RStudio Pro instance following the instructions in one of these topics:

On the Configure RStudio page for either type of integration, scroll down and check the box for Initialize Schema Viewer.

Use the LabKey Schema within RStudio

The RStudio viewer will now allow you to browse the LabKey schema. Select a project from the menu circled in this screenshot, then select a folder to see the schema it contains, and a schema to see the queries it contains.

Create Shiny Apps

Once you have integrated either RStudio or RStudio Pro with LabKey Server, you can create Shiny reports using LabKey data. This example shows an integrated Shiny app giving user control of a live visualization of viral load over time.

Extend Initialization

An RStudio system administrator can add or overwrite variables and settings during initialization by including an R function in the Rprofile.site file which calls the hidden/named function "labkey.rstudio.extend". When performing this initialization, a one time "requestId" is used, rather than a more persistent api key.

As an example, the following screenshot shows a simple call of this function which will print a 'Welcome' message:

RStudio executes the hidden function upon initialization:

Related Topics