Commander {Rcmdr} | R Documentation |
Start the R Commander GUI (graphical user interface)
Commander()
Getting Started
The default R Commander interface consists of (from top to bottom) a menu bar, a toolbar, a log/script window, and an output window.
Commands to read, write, transform, and analyze data are entered using the menus in the menu bar at the top of the Commander window. Most menu items lead to dialog boxes requesting further specification. I suggest that you explore the menus to see what is available.
Below the menu bar is a toolbar with (from left to right) an information field displaying the name of the active data set; buttons for editing and displaying the active data set; an information field showing the active statistical model; and a Submit button for re-executing commands in the log/script window. The information fields for the active data set and active model are actually buttons that can be used to select the active data set and model from among, respectively, data frames or linear and generalized linear model objects in memory.
Almost all commands require an active data set. When the Commander starts, there is no active data set, as indicated in the data set information field. A data set becomes the active data set when it is read into memory from an R package or imported from a text file, SPSS data set, or Minitab data set. In addition, the active data set can be selected from among R data frames resident in memory. You can therefore switch among data sets during a session.
By default, commands are logged to the log/script window (the initially empty text window immediately below the toolbar); commands and output appear in the output window (the initially empty text window below the log/script window); and the active data set is attached to the search path. To alter these and other defaults, see the information below on configuration.
Some Rcmdr
dialogs (those in the Statistics -> Fit models menu)
produce linear or generalized
linear models. When a model is fit, it becomes the active model, as indicated in the information
field in the R Commander toolbar.
Items in the Models menu apply to the active model. Initially, there is no active model.
If there are several models in memory, you can select the active model from among them.
If command logging in turned on, R commands that are generated from the menus and dialog boxes are entered into the log/script window in the Commander. You can edit these commands in the normal manner and can also type new commands into the log/script window. Individual commands can be continued over more than one line, but each line after the first must be indented with one or more spaces or tabs. The contents of the log/script window can be saved during or at the end of the session, and a saved script can be loaded into the log/script window. The contents of the output window can also be edited or saved to a text file.
To re-execute a command or set of commands, select the lines to be executed using the mouse and press the Submit button at the right of the toolbar (or Control-R, for "run"). If no text is selected, the Submit button (or Control-R) submits the line containing the text-insertion cursor. Note that an error will be generated if the submitted command or commands are incomplete.
Pressing Control-F brings up a find-text dialog box (which can also be accessed via Edit -> Find) to search for text in the log/script window or the output window. Edit functions such as search are performed in the log/script window unless you first click in the output window to make it the active window.
Right-clicking the mouse (clicking button 3 on a three-button mouse) in the log/script or output window brings up a "context" menu with the Edit-menu items, plus (in the log/script window) a Submit item.
When you execute commands from the Commander window, you must ensure that the sequence of commands is logical. For example, it makes no sense to fit a statistical model to a data set that has not been read into memory.
Exit from the Commander via the File -> Exit menu or by closing the Commander window.
Customization and Configuration
Configuration files reside in the etc
subdirectory of the package.
The Rcmdr
menus can be customized by editing the file Rcmdr-menus.txt
.
Some functions (e.g., hist
) that do not normally create visible printed output when executed
from the R Console command prompt will do so — unless prevented — when executed from the
Commander log window. Such output
can be suppressed by listing the names of these functions in the log-exceptions.txt
file.
You can add R code to the package, e.g., for creating additional dialogs, by placing files with
file type .R
in the etc
directory, also editing Rcmdr-menus.txt
to provide
additional menus, sub-menus, or menu-items. A demo addition is provided in the file
BoxCox.demo
. To activate the demo, rename this file to BoxCox.R
,
and uncomment the corresponding menu line in Rcmdr-menus.txt
. Alternatively, you can edit
the source package and recompile it.
The following functions are provided to assist in writing dialogs: activeDataSet
,
activeModel
, doItAndPrint
, justDoIt
, listDataSets
,
listGeneralizedLinearModels
, listLinearModels
, logger
. The following global
variables contain information about variables in the active data set: .factors
,
.numeric
, .twoLevelFactors
, .variables
. See help("Rcmdr.Utilities")
and the manual supplied in the etc
directory of the Rcmdr
package for more information.
In addition, several features are controlled by run-time options, set via the options("Rcmdr")
command. These options should be set before the package is loaded. If the options are unset, which is
the usual situation, defaults are used. Specify options as a list of name=value pairs. You can
set none, one, several, or all options. The available options are as follows:
attach.data.set
TRUE
(the default), the active data set is attached to the
search path.log.commands
TRUE
(the default), commands are echoed to the log/script window;
if FALSE
, the log/script window is not displayed.log.text.color
"black"
.log.font.size
log.width
log.height
log.height
to 0 has the same effect as setting log.commands
to FALSE
.console.output
TRUE
, output is directed to the R Console, and the
R Commander output window is not displayed. The default is FALSE
.output.height
output.height
to 0 has the same effect as setting console.output
to TRUE
.command.text.color
"red"
.output.text.color
"blue"
.placement
"-40+40"
, which puts the window near the upper-right corner of the screen.contrasts
contrasts
option; the default is
c("contr.Treatment", "contr.poly")
. When the Commander exits, the contrasts
option is returned to its pre-existing value. Note that contr.Treatment
is from the car
package.grab.focus
TRUE
(the default) for the current Tk window to
"grab" the focus — that is, to prevent the focus from being changed to another Tk window.
On some systems, grabbing the focus in this manner apparently causes the OK, Cancel, and
Help buttons to be disabled after the user types in a text field. If you experience this
problem, set the grab.focus
option to FALSE
.double.click
TRUE
if you want a double-click of the left mouse
button to press the default button in all dialogs. The default is FALSE
.multiple.select.mode
"extended"
(the default), left-clicking on a variable selects it and deselects any other
variables that are selected; Control-left-click toggles
the selection (and may be used to select additional variables); Shift-left-click extends the selection.
This is the standard Windows convention. If set
to "multiple"
, left-clicking toggles the selection of a variable and may be used to select more than one
variable. This is the behaviour in the Rcmdr prior to version 1.9-10.sort.names
TRUE
(the default) if you want variable names to be sorted
alphabetically in variable lists.show.edit.button
TRUE
(the default) if you want an Edit button in the Commander
window, permitting you to edit the active data set. Windows users may wish to set this option to FALSE
to suppress the Edit button because changing variable names in the data editor can cause R to crash.scale.factor
NULL
.default.font.size
"*helvetica-medium-r-normal-*-xx*"
, where xx
is the default font size. This option is only for non-Windows systems.default.font
tkwait
tkwait
option to
TRUE
; otherwise set the option to FALSE
or ignore it.
An undesirable side effect of setting
the tkwait
option to TRUE
is that the R session command prompt is suppressed until the Commander exits.
One can still enter commands via the log/script window, however. In particular, there is no reason to use this option
under Windows, and it should not be used with the Windows R GUI with buffered output.Many options can also be set via the File -> Options menu, which will restart the Commander after options are set.
John Fox jfox@mcmaster.ca
options(Rcmdr=list(log.font.size=12, contrasts=c("contr.Sum", "contr.poly")))