Customizing RStudio
Overview
The available options for the RStudio IDE are accessible from the Options dialog Tools > Options menu (RStudio > Preferences on a Mac), and include the following categories:
- General R Options — Default CRAN mirror, initial working directory, workspace and history behavior.
- Source Code Editing — Enable/disable line numbers, selected word and line highlighting, soft-wrapping for R files, paren matching, right margin display, and console syntax highlighting; configure tab spacing; set default text encoding.
- Appearance and Themes — Specify font size and visual theme for the console and source editor.
- Pane Layout — Locations of console, source editor, and tab panes; set which tabs are included in each pane.
- Packages — Set default CRAN repository and specify package development options.
- Sweave — Configure Sweave compiling options and PDF previewing.
- Spelling — Choose main dictionary language and specify spell checking options.
- Git/SVN — Configure locations of Git and Svn binaries and create and/or view SSH RSA keys.
- Publishing — Enable publishing apps and documents from IDE. Set account.
Details on the various settings are provided in the sections below.
General R Options
- Default working directory — Startup directory for RStudio (when not in a project). The initial .RData and .Rprofile files (if any) will be read from this directory. The current working directory and Files pane will also be set to this directory. Note that this setting can be overridden when launching RStudio using a file association or a terminal with a command line parameter indicating the initial working directory.
- Restore most recently opened project at startup — When opening RStudio automatically re-open the most recently used project.
- Restore previously open source documents at startup — When opening RStudio automatically re-open the source documents previously open for the current project.
- Restore .RData into workspace at startup — Load the .RData file (if any) found in the initial working directory into the R workspace (global environment) at startup. If you have a very large .RData file then unchecking this option will improve startup time considerably.
- Save workspace to .RData on exit — Ask whether to save .RData on exit, always save it, or never save it. Note that if the workspace is not dirty (no changes made) at the end of a session then no prompt to save occurs even if Ask is specified.
- Always save history (even when not saving .RData) — Make sure that the .Rhistory file is always saved with the commands from your session even if you choose not to save the .RData file when exiting.
- Remove duplicate entries in history — Prevent addition of commands to history if they are the exact same as the most recently added command.
- Use debug error handler only when errors contain my code — Only do special error handling (stopping in the debugger or showing the error inspector) when one of the functions on the stack contains my code.
- Automatically expand tracebacks in error inspector — Immediately show the traceback when errors are displayed in the error inspector.
- Default text encoding — Specify the default text encoding for source files. Note that source files which don't match the default encoding can still be opened correctly using the File : Reopen with Encoding menu command.
Source Code: Editing
- Insert spaces for tab — Determine whether the tab key inserts multiple spaces rather than a tab character (soft tabs). Configure the number of spaces per soft-tab.
- Insert matching parens/quotes — When typing a paren, quote, or brace automatically insert a matching one and position the cursor between them.
- Auto-indent code after paste — Automatically execute a Reindent on blocks of R code pasted into the editor.
- Vertically align arguments in auto-indent — Preserve the current indentation level for function arguments split across multiple lines.
- Soft-wrap R source files — Wrap lines of R source code which exceed the width of the editor onto the next line. Note that this does not insert a line-break at the point of wrapping, it simply displays the code on multiple lines in the editor.
- Ensure that source files end with a new line
- Strip trailing horizontal whitespace when saving
- Continue comment when inserting new line
- Enable vim editing mode — Use vim keybindings for editing and navigation rather than the default keybindings.
- Always execute R scripts before sourcing
- Focus console after executing from source — Move the focus to the console after executing a line or selection of code within the source editor.
- Enable code snippets
Source Code: Display
- Highlight selected word — Add a background highlight effect to all instances of the currently selected word within the document.
- Highlight selected line — Add a background highlight effect to the currently selected line of code.
- Show line numbers — Show or hide line numbers within the left margin.
- Show margin — Display a margin guide on the right-hand side of the source editor at the specified column.
- Show whitespace characters — Display glyphs indicating where whitespace characters (tab, newline, etc.) are located in source documents.
- Show indent guides — Display a line indicating the current indentation column.
- Blinking cursor
- Show syntax highlighting in console input — Apply R syntax highlighting to the console input line.
Source Code: Completion
- Show code completions — Select when to have editor display code-completion options as you type.
- Allow automatic completions in console
- Insert parentheses after function completions
- Show help tooltip after function completions — Check to display a summary of a function's help page in a small pop-up window after a code completion.
- Insert spaces around equals for argument completions — Check or uncheck to set code style for code completions.
- Use tab for multiline autocompletions
- Show completions after characters entered — Enter the minimum number of characters necessary to trigger a code completion.
- Show completions after keyboard idle — Select how long the editor should wait after you stop typing before it should automatically suggest a code completion.
Source Code: Diagnostics
- Show diagnostics for R — Check to display alert messages in the margin of the editor when R code appears incorrect.
- Enable diagnostics within R function calls
- Check arguments to R function calls
- Warn if variable used has no definition in scope
- Warn if variable is defined, but not used
- Provide R style diagnostics (e.g. whitespace) — Check to display alert messages in the margin of the editor when R code appears to be styled poorly.
- Show diagnostics for C/C++ — Check to display alert messages in the margin of the editor when C or C++ code appears incorrect.
- Show diagnostics for JavaScript, HTML, and CSS — Check to display alert messages in the margin of the editor when JavaScript, HTML, and CSS code appears incorrect.
- Show diagnostics whenever source files are saved
- Show diagnostics after keyboard is idle for a period of time
Appearance and Themes
- Editor font — Customize the font for panes which display code (Console, Source, History, and Workspace).
- Font size — Set the font size (in points) for panes which display code (Console, Source, History, and Workspace).
- Editor theme — Specify the visual theme for the Console and Source panes. You can preview the theme using the inline preview or by pressing the Apply button.
Pane Layout
- Specify the location and tab sets of panes within RStudio.
- Each of the 4 panes is always displayed (it isn't currently possible to hide a pane).
Packages
- CRAN mirror — Set the CRAN mirror used for installing packages (can be overridden using the repos argument to install.packages).
- Enable packages pane — Show the packages pane (it might be useful to disable it if you have hundreds of packages installed and listing them all causes performance problems).
- Use devtools package functions if available — If the devtools package is installed, use its functions to build, load, and manage packages.
- Save all files prior to building packages — Automatically save open source editor documents prior to executing package build commands.
- Automatically navigate editor to package build errors — When a package build error occurs that has an identifyable source file and line number automatically open the file and navigate to the error location.
- Hide object files in package src directory — Hide object files created as a side effect of builds in the package src directory.
- Cleanup output after successful R CMD check — When R CMD check succeeds remove the source package and Rcheck directory that are created as part of the check.
- View Rcheck directory after failed R CMD check — When R CMD check fails automatically navigate the files pane to the Rcheck directory for inspection of the various diagnostic log files.
- Use Rcpp template when creating C++ files — Start new C++ files with a simple example of exporting a C++ function to R via Rcpp.
Sweave
- Weave Rnw files using — Choose the default global option for weaving files with the Compile PDF button. (See Weaving Rnw Files for additional documentation).
- Typeset LaTeX into PDF using — Choose from a list of supported typesetting engines or add a customized one (See additional help for Customizing LaTeX Options).
- Clean auxiliary output after compile — Running the LaTeX program produces various intermediate files (e.g. 'target.out', 'target.aux'). Enabling this option causes these files to be automatically removed after the compile. Note that log files ('target.blg' and 'target.log') are also cleaned up, however they are preserved if errors occur during compilation.
- Enable shell escape commands — Enable execution of shell commands using
\write18
by passing the-shell-escape
option to the LaTeX program. This option is disabled by default because allowing documents to execute embedded shell commands may pose a security risk. - Insert numbered sections and subsections — Specifies that sections and sub-sections inserted using the Format menu should include numbering (if this option is not enabled then sections will be inserted as
\section*
). - Preview PDF after compile using — Choose which application to view your PDF file with after the compile is complete. (See additional help for PDF Preview).
- Always enable Rnw concordance — Automatically set the options required to emit concordance information during Rnw weaving. Concordance provides a mapping between line numbers in the Rnw file and the generated TeX file. This enables both direct navigation to compilation errors within Rnw files and compatibility with Synctex for PDF previewing.
Spelling
- Main dictionary language — RStudio's default installation includes English dictionaries for the US, UK, Canada, and Australia. In addition, dictionaries for 28 other languages can be installed. For additional information on dictionaries, see the Spelling Dictionaries documentation.
- Custom dictionaries — You can also configure RStudio to use Hunspell custom dictionaries that include additional terms commonly used within your field. For additional information on customizing dictionaries, see the Spelling Dictionaries documentation.
- Ignore words in UPPERCASE — Ignore words in all UPPERCASE letters while spell checking
- Ignore words with numbers — Ignore words with numbers while spell checking
Git/SVN
- Git executable — Location of Git executable. By default RStudio locates the Git executable in the system path. If you want to use a version of Git not on the path you can specify it here.
- SVN executable — Location of SVN executable. By default RStudio locates the SVN executable in the system path. If you want to use a version of Git not on the path you can specify it here.
- SSH RSA Key — When using SSH with RSA public/private key authentication against a remote Git or Subversion repository you need to generate an RSA key and then provide the public key to the remote server. You can both create a new RSA key and view/copy its public key within the Version Control options panel.
Publishing
- Publishing Accounts — List of accounts that the session has access to publish to.
- Enable publishing apps and documents — Allow user to deploy apps or documents to an external account by clicking the publish icon or by executing a publish command.
Need Help?
RStudio Workbench (previously RStudio Server Pro) customers may open a discussion with RStudio Support at any time with these instructions.
You may also ask for help from R and RStudio users on community.rstudio.com. Be sure to include a reproducible example of your issue. Click here to start a new community discussion.
Comments