Working with the R Console
- You can use the R Console to interact with the R programming language.
- The R Console includes a variety of features intended to make working with R more productive and straightforward, including: code completion, command history and access to help.
- Code completion:
- In the Console, you might begin typing a command and then be unsure if you’re spelling it correctly. You can activate the code completion feature by hitting the
<tab>
button. This will bring up a list of possible completions. You can press <esc>
to cancel that list of options, and you can use the arrows keys and hit <tab>
(or select via your mouse) to choose a completion.
- Command history:
- As you work with R, you’ll often want to re-execute a command which you previously entered, possibly with some changes.
- The RStudio Console supports the ability to recall previous commands using the arrow keys. You can scroll through the history in both directions by using the up/down arrow keys while in the Console pane. A common workflow is to incrementally build a task by starting with a simple command, then using the up arrow to recall it and extend it by adding more steps.
- You can also use the History pane in the upper-right section to see a list of all previously entered commands. Double-clicking any of these commands will paste it into the Console.
- Getting help:
- In the Console, use a prepended
?
to pull up the R documentation for any R command. For instance, typing ?print
in the console will bring up the documentation for the print
command.
- Alternativaly you can use the
help
command: help(print)