Setting up your S-PLUS environment

Before really learning how to use S-PLUS to do many statistical tasks, we will want to learn how to make it easier to use. This will take you through the steps of creating your own class directory to store S-PLUS objects specific to this class, and creating a function which will automatically open up a graphics window and the graphical S-PLUS help window.

Creating a separate .Data directory.

First, make sure that you are in your home directory. Type
% pwd
/home/users/your-login-name
for "print working directory". (You should type commands after the % prompt. The rest should appear on your screen.) If you are someplace else, typing
% cd
/home/users/your-login-name
for "change directory" without any other arguments returns you to your home directory. To create a directory called 496 to keep Math 496 related material, create a subdirectory called .Data and then create a file called .Audit in the .Data subdirectory do the following.
% mkdir 496
% cd 496
/home/users/your-login-name
% mkdir .Data
% touch .Data/.Audit
The command mkdir is for "make directory". The command touch creates an empty file. All objects you create in an S-PLUS session which begins in the directory 496 will be stored in the directory .Data. The file .Audit keeps a list of all commands you have typed in S-PLUS which allows you to access and reuse or edit old commands.

Creating a .First function

Almost every time you wish to run S-PLUS, you will want to have a graphics window for plotting data and the online help window open to look things up. You will also wish to use emacs style keystrokes to edit old commands. These commands will start S-PLUS and create a function called .First which does these things. The function will execute automatically every time you start S-PLUS.

Make sure you are in the 496 directory. (Use pwd.) Then,

% Splus -e
S-PLUS : Copyright (c) 1988, 1995 MathSoft, Inc.
S : Copyright AT&T.
Version 3.3 Release 1 for Sun SPARC, SunOS 5.3 : 1995 
Working data will be in .Data 
> .First <- function(){
+ options(gui="openlook",editor="emacs")
+ openlook()
+ help.start()
+ }
The flag -e after the command Splus tells the computer to start S-PLUS with command line editing turned on. (We will learn more about this later.) The prompt > tells you that S-PLUS is ready for you to type in a command. The prompt + lets you know that S-PLUS needs more input to be able to interpret the command you've given it. The set of symbols <- is the assignment operator in S-PLUS. The name of the function you create is called .First. The function consists of the S-PLUS commands between the curly braces. When S-PLUS starts, it will execute those three commands automatically just as if you had typed them. The first command, options, tells the program that you are using the OPEN LOOK window manager (even though you might not have that) and that the editor you wish to use is emacs. The second command opens a graphics window under OPEN LOOK and the third opens the online help window.

Try this out by quitting S-PLUS and then restarting.

> q()
% Splus -e
A graphics window and the help window should open on your screen.

You are now ready to begin learning to use S-PLUS. Use a link below to take you to your next topic.



Last modified: March 10, 1997

Bret Larget, larget@mathcs.duq.edu