-
-
Notifications
You must be signed in to change notification settings - Fork 85
Editor Setup
We recommend to use an editor with integrated R support. Some popular choices include:
- RStudio: Recommended if you are not already familiar with vi/emacs.
- vim/neovim with Nvim-R plugin
- emacs with ESS
In all project, we use the following settings:
- Files are stored in UTF-8
- Unix line breaks (
\lf
/\n
) - 2 Spaces for intendation, no tabs
- Trim trailing whitespace
In order to make it easier to switch back and forth between projects, these settings are also defined in configuration files in the git reposities.
All packages from the mlr3verse come with a [pkg].Rproj
file which applies the required settings.
Most other coding editors (including vim, emacs, sublime, atom, ...) support EditorConfig via the .editorconfig
file in the git root directory.
You probably just need to install the respective plugin, and all required settings are applied accordingly.
The styler package has the ability to apply the mlr_style
to either the active file or the whole package.
The easiest way to apply the style is via the RStudio-addin. By default the addin will apply the "tidyverse style". To change this behavior, you need to first install the "mlr" branch via
remotes::install_github("pat-s/styler@mlr-style")
And append the following to your own .Rprofile
:
if (grepl("mlr", getwd()) || grepl("paradox", getwd())) {
options(styler.addins_style_transformer = "mlr_style()")
}
The setting options(styler.addins_style_transformer = "mlr_style()")
ensures that the mlr_style
will be used for this project when you run styler::style_active_file()
.
To make this task even more convenient, we recommend to map styler::style_active_file()
to a shortcut in RStudio. Go to Tools -> Modify Keyboard Shortcuts
and search for "Styler". Next, click into the "Shortcut" field and press the desired key-combination you want to use.
Use the ale plugin to use styler
as a "fixer".
Install the R package with remotes::install_github("lorenzwalthert/styler@mlr-style")
.
Next, with your favorite plugin manager, set the following plugin options:
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'r': ['styler'],
\}
let g:ale_r_styler_options = 'styler::mlr_style'
To apply the style guide in a R file, you need to call :ALEFix
.
This can be mapped to a binding as follows:
nmap <F8> <Plug>(ale_fix)
CI
Roxygen (Documentation)
Style
Misc