RStudio® Workbench

To use RStudio® Workbench, your platform administrator must first configure its operational license in Control Panel.

Code Workspaces enables you to use RStudio® Workbench ↗ in Foundry. RStudio® Workbench in Code Workspaces supports:

  • Reading and writing tabular datasets using the Palantir R SDK ↗.
  • Downloading or uploading files from non-structured datasets.
  • Importing R packages from CRAN, Posit™ Package Manager, and Bioconductor.
  • Publishing Shiny® applications.
  • Publishing R transforms.

Code Workspaces currently supports Shiny® ↗ for R applications. Users can create applications directly in Code Workspaces with Foundry’s version control, branching, and data governance features built-in.

Code Workspace applications support branching. If you create a new Workspace branch, publishing a new application or synchronizing the changes will publish a new version of the application on that branch. This allows you to preview your application before exposing it to your users. To publish on the master branch, simply merge your branch into master.

Shiny®

With Code Workspaces, you can create a Shiny® application and preview it directly from the RStudio® UI.

By default, RStudio® generates Shiny® applications in the home folder (/home/user) but Foundry requires applications to be in the git repository /home/user/repo for them to be persisted across sessions and published.

In Code Workspaces, select Publish application, select a location in your Files and Projects for your new application, and enter the name of the directory in which a new Shiny® app.R file should be automatically created, relative to the repository root /home/user/repo. This field can be left blank to create the application at the root of the repository. By default, the application settings will match the RStudio® workspace settings, and configuring advanced settings is optional.

Published Shiny applications are subject to a 30-second timeout, meaning that the Shiny server must start up within 30 seconds of executing your Shiny application file. Otherwise, your Shiny application will fail to start up.

Select Publish and sync to register your new Shiny® application and sync the code to the backing code repository. After CI checks and publishing are complete, you can select the link in the Applications panel to view the published application.

To develop locally against a Shiny® application:

  1. Open app.R in RStudio®.
  2. Select Run App. A preview of your application will appear in a new window.

Configure Shiny® applications to automatically reconnect

By default, Shiny greys out if the websocket connection is closed, for instance if there is a network outage for over 15 seconds. To ensure your application can recover when the network connection is restored, we recommend updating the server function to set session$allowReconnect("force"):

server <- function(input, output, session) {
  # Handle input changes
  session$allowReconnect("force")
}

This will cause the frontend to trigger a new websocket when the network is available again, and to send the last input information that was set in the UI.

R Transform

R transforms currently do not support making API calls to external services, even if the network policy was added in the RStudio Code Workspace.

R scripts written in Code Workspaces can be registered as transforms for output datasets in Code Workspaces.

Follow the steps below to register a transform for an output dataset:

  1. Select the blue Build icon next to the dataset in the Data panel.
The blue build button to the right of the dataset name.
  1. Follow the interface to configure your transform. Code Workspaces infers the R script used along with the inputs added to produce the output dataset.
The Edit Transform pane,l with options to modify the script file, inputs, and outputs and adjust the CPU and Memory.
  1. Select Sync and run to save the transform configuration and trigger CI checks for publishing the transform and JobSpecs on the output dataset(s).

Once CI checks are completed, your transform is ready for build. You can then use other Foundry data integration tools to manage your transform and the data pipeline to which it belongs.

The transform does not automatically use the environment of the Code Workspace. You should install all the packages needed at runtime at the top of the script file. The code snippet to install a package can be found in the Packages panel. For example, to use dplyr and tidyr in your transform, add this code snippet to the top of the file:

renv::install(c("dplyr", "tidyr"))

Learn more about R transforms.


RStudio® and Shiny® are trademarks of Posit™.

All third-party trademarks (including logos and icons) referenced remain the property of their respective owners. No affiliation or endorsement is implied.

R Markdown Reports

R Markdown files written in RStudio® workspaces can be shared with other Palantir platform users with R Markdown Reports. A report is a dataset built from an R Markdown file using a transform, containing HTML produced by rendering the R Markdown file with Quarto ↗.

Reports are built using transforms, so they can be configured to automatically update based on the latest changes to the R Markdown file using a schedule. This ensures that your analyses and visualizations are up-to-date and built with a reproducible, customizable workflow that integrates with the rest of the Palantir platform.

The Reports side panel in Code Workspaces.

Publish reports from an RStudio® workspace

An R Markdown report can be published in an RStudio® workspace using the following steps:

  1. Create the R Markdown file you wish to use to build input. This R Markdown file can read from Foundry datasets that have been added to your workspace using the Data side panel.
  2. Open the Applications side panel and select the Reports tab.
  3. Select Add to open the report configuration dialog.
  4. Provide a name and location; this determines where the dataset containing the report will be saved.
  5. Select the R Markdown file to build your report from. If your R Markdown reads from Foundry datasets, add these datasets as report inputs. Select Auto-configure inputs and outputs to automatically parse your R Markdown file and populate the form with any detected datasets.
  6. Select Create. This will create a dataset at the specified location. The transform that builds the report will then run. Note that this can take several minutes to complete.
  7. Once the report has been built, select the report name in the Applications side panel to open the report in a new tab. This link can be shared with other users.

To edit or delete an existing report, select ... on the right of the report card. This will open a menu with options to edit or delete the report, and an option to copy the link to the report.

View previous report versions

Reports support full version history. To view a previous version of a report, expand the report card in the Applications side panel or use the version selector in the page header when viewing a report in a new tab.

Selecting a report version will update the link used to share the report, enabling you to share a specific historical version of a report that will not be updated if the underlying R Markdown is modified.

Previewing an R Markdown report in a new tab.

The latest version of a report will be selected by default, so readers of your report automatically receive the latest changes.