如何在 RStudio 中持久保存和共享代码How to persist and share code in RStudio

问题Problem

与内置了版本控制的 Azure Databricks 笔记本不同,当关闭托管 Rstudio 的高并发群集时,RStudio 中开发的代码将丢失。Unlike a Azure 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

若要在 RStudio 中持久保存和共享代码,请执行以下操作之一:To persist and share code in RStudio, do one of the following:

  • 在 RStudio 中,将代码保存到 DBFS 上的一个文件夹中,该文件夹可从 Azure Databricks 笔记本和 RStudio 中访问。From RStudio, save the code to a folder on DBFS which is accessible from both Azure Databricks notebooks and RStudio.
  • 在 RStudio 中使用 Git 等版本控制的集成支持。Use the integrated support for version control like Git in RStudio.
  • 将 R 笔记本导出为,将其保存到本地文件系统 Rmarkdown ,然后将该文件导入到 RStudio 实例中。Save the R notebook to your local file system by exporting it as Rmarkdown, then import the file into the RStudio instance.

博客使用 RMarkdown 共享 R 笔记本更详细地介绍了这些步骤。The blog Sharing R Notebooks using RMarkdown describes the steps in more detail.

此过程允许你保留在 RStudio 中开发的代码,并在 Azure Databricks 笔记本环境与 RStudio 之间共享笔记本。This process allows you to persist code developed in RStudio and share notebooks between the Azure Databricks notebook environment and RStudio.