2.3 Console pane tricks
R is unforgiving: even the slightest spelling mistake will cause an error. It is therefore not uncommon to experiment with a command before it does exactly what you want. RStudios’ console pane offers several nice features to make that a little less painful.
2.3.1 Browsing past commands
A particularly helpful feature: you can use the arrow keys to easily retrieve a previously typed command. The arrow-up button lets you browse your command-history backward. Press it once, and you’ll see your last command. Hit it a second time, and the before-last command pops up. Neat, right?
In case you passed the command you were looking for, you can use the arrow-down key to browse it forward. Try it out!
In addition, you can trigger a drop-down menu that lists all your past commands with ctrl
+ the arrow up key.
2.3.2 Auto-completion
RStudio provides auto-compleition suggestions while typing. Just type part of a command and pause a little anda drop-down menu with suggestions shows up. From it, you can choose the function or variable name you are looking for and hit return. For instance, assume you declared the variable
If you now type terr
a wait for a second, that horribly long variable name shows up in the dropdown for you to choose. And rather than using your arrow keys to choose an option, you can also continue typing until the first choice is what you were looking for and then hit return.
Good to know: if you are impatient or the auto-compleition dialog does not show up, just hit ctrl
+ space
to trigger it.