RStudios GUI – the console
Hints for the RStudio console
1 Hints for working in the console
As mentioned elsewhere, the console lets you talk directly to the R interpreter and you will spend much time in the console testing out your code.
Here follows a number of practical simple hints on how to use the console:
1.1 Predictive texting
mean
in the console and wait a short while – RStudio will present you with a list of functions etc in the current environment that starts with mean. Try scrolling through the list.1.2 Predictive texting .. which is adaptive
meaning_of_life <- 52
(ENTER) to create a new variable – now try out hint #1 again and you will see this new variable has been added to the list.1.3 Re-use and ammend previous commands
But the meaning of life is not 52, is it?1 So we need to fix that.
1.4 Sweeping away the clutter
1.5 Running a command from the text editor
print("copy, paste, execute")
(CTRL+ENTER) – this command should be copied into the console and executed immediately.1.6 Running multiple commands from the text editor
print("with CTRL-ENTER")
– this time, highlight both lines (mouse: click+drag) before CTRL+ENTER.Hint Check out the ‘Run’ dropdown button in the top right-hand corner of the text editor, to run all code or specific chunks.
To copy the other way, from console to text editor, use the usual mouse-hightlight, CTRL-c and CTRL-v to copy paste.
Footnotes
According to the fictional supercomputer Deep Thought in Douglas Adams’ sci-fi universe, The Answer to the Ultimate Question of Life, The Universe, and Everything, is 42, but you probably already knew that :-)↩︎