How to persist and share code in RStudio

Learn how to share notebooks between Databricks and RStudio.

Written by Adam Pavlacka

Last published at: May 20th, 2022

Problem

Unlike a Databricks notebook that has version control built in, code developed in RStudio is lost when the high concurrency cluster hosting Rstudio is shut down.

Solution

To persist and share code in RStudio, do one of the following:

  • From RStudio, save the code to a folder on DBFS which is accessible from both Databricks notebooks and RStudio.
  • Use the integrated support for version control like Git in RStudio.
  • Save the R notebook to your local file system by exporting it as Rmarkdown, then import the file into the RStudio instance.

The blog Sharing R Notebooks using RMarkdown describes the steps in more detail.

This process allows you to persist code developed in RStudio and share notebooks between the Databricks notebook environment and RStudio.