Kickstarting R
Starting and stopping

Starting R

If R has been installed properly, simply entering R on the command line of a terminal should start the program. In Windows, the program is typically specified as the action performed when clicking on an icon. You can also use this method on a *NIX system that has a window manager such as KDE.

Where does it start?

R normally starts in the current directory, unless the command associated with it specifies something different. A handy way of building working directory specification into the R startup file is to add the following line:

-s) shift; cd $1 ;;

to the R script just before the line that begins:


at about line 120. This allows you to start R with a command line like:

> R -s /home/jim/R/analyses

Now this may not seem like much use as a command line, unless it is the command that is run by one of a number of icons. You can then have several R icons that will start up in different directories with different data sets, making the management of your data a bit easier. Another way, described in The R Script is to include the directory change in a script file.

Stopping it

R has a function q() that will end the session, asking if you want to add the objects and commands from the current session to the .RData and .Rhistory files respectively. If you decline, whatever was in there prior to the current session will remain. There is also a .Last() function that can be used to automate your exit.

For more information, see An Introduction to R: Using R interactively.

Back to Table of Contents