Often we will be interacting with R by writing code and sending
that code to the R Interpreter so that it can be run (locally or
remotely). It is always good practice to store this code into a file
so that we have a record of what we have done and are able to
replicate the work at a later time. Such a file is called an R
Script.
We can create a new R Script by clicking on the first icon on the
toolbar and choosing the first item in the resulting menu
as in Figure 2.2. A keyboard
shortcut is also available to do this: Ctrl+Shift+N (hold the
Ctrl and the Shift keys down and press the
N key).
A sophisticated file editor is presented as the top left pane within
. The tab will initially be named Untitled1 until we
actually save the script to a file on the disk. When we do so we will
be asked to provide a name for the file.
The editor is where we write our R code and compose the programs
that instruct the computer to perform particular tasks. The editor
provides numerous features that are expected in a modern program
editor. These include syntax colouring, automatic indentation to
improve layout, automatic command completion, interactive command
documentation, and the ability to send specific commands to the R
Console to have them run by the R Interpreter.
Figure:
Ready to edit R
scripts in using the Editor pane on the top
left created when we choose to add a new R Script from the
toolbar menu displayed by clicking the icon highlighted in red.