Skip to content

Celda Development Rstudio configuration

Zhe Wang edited this page May 24, 2019 · 5 revisions

Rstudio Configuration

Below is a list of Rstudio (Version 1.1.463) settings and tricks that help with writing R codes consistent with the celda coding style guide.

Under tools -> Global Options -> General:

  • Basic
    • Restore .RData into workspace at startup (Unchecked) [IMPORTANT!]
    • Save workspace to .RData on exit: Never

Under tools -> Global Options -> Code:

  • Editing
    • Insert spaces for tab (Checked)
      • Tab width 4
    • Auto-indent code after paste (Checked)
    • Vertically align arguments in auto-indent (Unchecked)
  • Display
    • Show line numbers (Checked)
    • Show Margin (Checked)
      • Margin column 80
    • Show whitespace characters (Checked)
  • Saving
    • Strip trailing horizontal whitespaces when saving (Checked)

There is a built-in R code auto-format function available in Rstudio. It's Code -> Reformat Code. It fixes some but not all of the coding style issues.

There is an R package called styler (GitHub repo) that does a similar job with more power.

styler example:

styler_example