The command line is where you interact with R. This is designated in red and has a “>” symbol. At the command line you type in code telling R what to do. You can use R as calculator to perform basic mathematical operations. Try typing some basic arithmetic tasks at the command line. Hit enter and R will compute the requested result: |2+9 | [1] 11|7*8| [1] 56 More than one line of code can be entered at the command line. Subsequent lines after the first line are designated by a “+” symbol. For example if you use an opening parenthesis and then hit enter you will get a “+” symbol and can continue writing code on the next line:|2*(| + 4+6)| [1] 20 If you enter something incorrect, or that R does not understand, you will get an error message rather than a result:|what |Error: Object "what" not found The Menu Bar The menu bar in R is very similar to that in most Windows based programs. It contains six pull down menus, which are briefly described below. Much of the functionality provided by the menus is redundant with those available using standard windows commands (CTRL+C to copy, for example) and with commands you can enter at the command line. Nevertheless, it is handy to have the menu system for quick access to functionality. File The file menu contains options for opening, saving, and printing R documents, as well as the option for exiting the program (which can also be done using the close button in the upper right hand corner of the main program window). The options that begin with “load” (“Load Workspace and “Load History”) are options to open previously saved work. The next chapter discusses the different save options available in some detail as well as what a workspace and a history are in terms of R files. The option to print is standard and will print the information selected. Edit The edit menu contains the standard functionality of cut, copy and paste, and select all. In addition, there is an option to “Clear console” which creates a blank workspace with only a command prompt (although objects are still in working memory), which can essentially clean a messy desk. The “Data editor” option allows you to access the data editor, a spreadsheet like interface for manually editing data discussed in depth in the next chapter. The last option on the edit menu is “GUI preferences” which pops up the Rgui configuration editor, allowing you to set options controlling the GUI, such as font size and background colors Misc The Misc menu contains some functionality not categorized elsewhere. The most notable feature of this menu is the first option c which can also be accessed with the ESC key on your keyboard. This is your panic button should you have this misfortune of coding R to do something where it gets stuck, such as programming it in a loop which has no end or encountering some other unforeseeable snag. Selecting this option (or ESC) should get the situation under control and return the console to a new command line. Always try this before doing something more drastic as it will often work. The other functionality provided by Misc is listing and removing objects. We will discuss working with objects in the next chapter. Packages The packages menu is very important, as it is the easiest way to load and install packages to the R system. Therefore, the entire section following this is devoted to demonstrating how to use this menu. Windows The Windows menu provides options for cascading, and tiling windows. If there is more than one window open (for example, the console and a help window) you can use the open Windows list on the bottom of this menu to access the different open windows. Help The Help menu directs you to various sources of help and warrants some exploration. The first option, called “Console” pops up a dialog box listing a cheat sheet of “Information” listing various shortcut keystrokes to perform tasks for scrolling and editing in the main console window. The next two options provide the FAQ (Frequently Asked Questions) HTML documents for R and R for the operating system you are using. These should work whether or not you are connected to the Internet since they are part of the program installation. The FAQ documents provide answers to technical questions and are worth browsing through. The next section on the help menu contains the options “R language (standard)”, “R language (HTML)”, and “Manuals”. “R language (standard) pops up the help dialog box in Figure 2-5. This will pop up the help screens for the specified term, provided you enter a correct term (which can be hard if you don’t know ahead of time what you’re looking for). This can also be accomplished using the help () command, as we will see in the next chapter.