You can keep your RStudio analysis by saving it as an R-Markdown file (.Rmd) in the Analyses tab of your workspace. Read on for the basics of launching RStudio from an .Rmd file and how to save, store, and delete it.
Note: Terra only recognizes R-Markdown files with the extension Rmd
. The capital 'R' is required.
Launching RStudio from an .Rmd file
All of your workspace's .Rmd files are listed under Your Analyses in the Analyses tab of your workspace. You can identify them by the "R" logo beside the filename.
Follow the instructions below to launch an RStudio analysis from one of these files.
-
1. Click on the .Rmd filename to open it.
2. Click the Open button (with a rocket symbol) beside the Preview (Read only) tab.
3. In the RStudio Cloud Environment pane, click Create.
4. Once your RStudio Cloud Environment is running, click the Open RStudio button.
5. This will open RStudio, and you can continue your analysis.
-
1. Click on the .Rmd filename to open it.
2. Click the R logo in the sidebar to resume the RStudio Cloud Environment.
3. Click Resume Environment (play icon).
The RStudio Cloud Environment will take a minute or two to resume.4. Once the environment is running (green dot in the sidebar), close the RStudio Cloud Environment pane ("x" at the top right) and click the Open RStudio button.
5. This will open RStudio, and you can go ahead with your analysis.
Saving RStudio analyses (autosave and more)
You can save any code you write in your Terra RStudio instance by creating a new file of the appropriate file type. Running code in the console is good for testing, but to export your code or save it to another location, you must create and save a file containing the code explicitly.
You can save your work as an R-Markdown (.Rmd) file from the File menu at the top of your RStudio instance.
Your files will display under Your Analyses in your workspace's Analyses tab.
Autosave
To ensure you don't lose your work, Terra autosaves files every 10 seconds (by default) to workspace storage (Google Bucket).
Autosave details
- Autosave syncs your work to workspace storage and your workspace's Persistent Disk in the background (changes persist).
- When the file is open, its autosave status is indicated by the color and content below the RStudio logo at the top left of the screen.
- To change the default autosave period, open the file and go to Options > Settings > Save.
Running long calculations?
Note that Terra will autosave if there is no activity in the browser, regardless of whether the VM is actively running calculations. If you are running a long calculation with autopause enabled, this may lead to Terra saving and pausing your work before the process has terminated (although it may also autosave the work you've done already).
If you are running a long calculation and don't want to babysit it, you may want to adjust the autopause so that it does not time out. See the article on How to adjust Cloud Environment autopause for more information.
Deleting unwanted .Rmd files
Delete all files in Terra (Analyses tab)When you finish your analysis and want to delete extra .Rmd files, delete them from the Analyses tab in Terra, not the RStudio instance. This keeps Terra from overwriting deleted files with an autosaved version.