Using and launching RStudio with .Rmd files

Allie Cliffe
  • Updated

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 in your workspace. 

Note: Terra only recognizes R-Markdown files with the extension Rmd. The capital 'R' is required

Launching RStudio from an .Rmd file

All created and saved 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. 
Screenshot of workspace Analyses tab with HellowWorld RMarkdown file in the Name column of the Your Analysis section and the R logo under the application column.

Step-by-step instructions

If you have saved R-Markdown files, you can create and launch an RStudio analysis by clicking on the file card in the Analyses tab. See step-by-step directions below.

  • 1. Click on the .Rmd file to open in the Name column.

    2. Click the Open button beside the Preview (Read only) tab. 

    3. In the RStudio Cloud Environment pane, click Create
    Screen capture of launching RTStudio from Rmd file following the instructions above
    The RStudio environment will take three-four minutes to create. Once it's ready, you'll see a green dot below the R logo in the sidebar. 

    4. Once your RStudio Cloud Environment is running, click the Open RStudio button.
    Screenshot of the Analyses tab with the Your cloud environment is ready popup and blue open RStudio button circled. A preview version of the file is visible in the main screen section

    5. This will open RStudio, and you can continue your analysis. 
    Screenshot of RStudio session in Terra with example standard output code in the entrypoint.out section at left, an empty environment section at the top right, and teh environment.out under files in the bottom right.

  • 1. Click on the .Rmd file to open in the Name column.

    2. Click the R logo in the sidebar to resume the RStudio Cloud Environment.  

    3. Click Resume Environment (play icon). 
    Screen capture of starting an RStudio instance by resuming a paused Cloud Environemnt following the instructions above.
    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.
    Screenshot of the Analyses tab with the Your cloud environment is ready popup and blue open RStudio button circled. A preview version of the file is visible in the main screen section.

    5. This will open RStudio, and you can go ahead with your analysis. 
    Screenshot of RStudio session in Terra with example standard output code in the entrypoint.out section at left, an empty environment section at the top right, and teh environment.out under files in the bottom right.

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.

Screenshot of RStudio instance in a Terra workspace with the File menu dropdown expanded. The save as option is visible at the bottom of the dropdown.

Your files will display under Your Analyses.

Screenshot of workspace Analyses tab with HellowWorld RMarkdown file in the Name column of the Your Analysis section and the R logo under the application column.

Autosave

To ensure you don't lose your work, Terra autosaves R-Markdown files every 10 seconds (by default) to workspace storage (Google Bucket). 

Autosave details

  • Background sync to workspace storage and PD (changes persist)
  • Indicated by the color and content below the RStudio logo (top left)
  • To change the default autosave period, 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 and don't want to sit and babysit it, you may want to adjust the autopause.

To learn more, see How to adjust Cloud Environment autopause.

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.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.