The R Editor is where the code is written in order to execute it in R.
With CTRL+R or CTRL+Enter, the current selection (or the current line if no selection) is executed in R. The green arrow in the top menu (CTRL+SHIFT+R) executes the whole file.
A right click shows the following options:
- Run current selection or line executes the selection or line, like CTRL+R or CTRL+Enter ;
- Comment / Uncomment selection (CTRL+SHIFT+C) comments / uncomments the selection ;
- Change All Occurrences (CTRL+F2) changes all occurrences of the current text at the same time ;
- Command Palette (F1) opens the command palette with more options.
You also have the following useful shortcuts:
- CTRL+F to search in the code ;
- CTRL+H to replace ;
- CTRL+G to go to a specific line.
The R Editor comes with an autocompletion with the existing R functions.
- TAB or Enter validates the proposition ;
- CTRL + Space or clicking on the (!) sign shows the description of the function (from the R documentation) ;
- Echap removes the autocompletion.
When the arguments are being written, the help is updated with the current argument.
For each variable or a word in a character string in the file, it provides it with the label
abc before, when no function matches the autocompletion.
When a personal function is written, it is added in the autocompletion system, whatever the function is defined in this file or in another of the project and whatever the function is in the R environment or not, as long as the file is saved.
The help of the function above is empty. It is possible to fill it, and even to fill the help for each argument of the function. This is done with the following syntax.
To do it, write a block comment at the top of the function with its description (which can be on several lines) and a single line for each argument, with the syntax
#' @param argument help.