Getting Started with S-Plus


This file is intended as an guide to accessing and starting operations in the S-Plus software package. It was written by F.E. Lindsay as part of an orientation toward the Department's software. PD & FEL 2/95. The S-Plus Guide to Statistics, Volumes I and II are now on-line in PDF format at http://www.splus.mathsoft.com/splus/resources/doc/.

Getting In

To begin the S-Plus program ...
tap splus
when prompted type ...
Splus
**Note: Be sure to use a capital "S."
Accessing Data Sets
The S-Plus program comes complete with a number of ready-made datasets. Many of these datasets you will be using for various S-Plus assignments. Documentation concerning these datasets can be found in the New S Language text, pages 643-661. To access these datasets simply type in the name of the dataset at the prompt. For instance to view the data named ship type ship. Note, however, that many of these datasets have several subsets that can only be called by giving the heading name, a period (.) and the subset name, such as rain.nyc1.
Entering & Working with Data
S-Plus offers some handy features for entering in your own data and for giving certain values a unique identifier. Note that the names given to the data and datasets you create are stored in a directory called yourname/.Data .

To assign a name to a value, or an expression use ...

name <- 1500
Entering name will produce the value 1500.

You can also enter in a group of values under a given name. To create simply enter the data using ...

name <- c(100, 200, 300)
Entering name will produce ...
[1] 100  200  300
Using a Text Editor
As you work with S-Plus using more complex and lengthy expressions and commands, you will notice the need for an external text editor program. The GLUE system offers many text editor programs, such as AXE, TEXT EDIT, PICO, and others (use the pull-down menu bar). The text editor allows you to type in data and S-Plus commands that can be cut and pasted into the S-Plus program window. This makes it possible to edit these expressions without re-typing all of the information. The cut and paste function can work slightly different depending on the text editor used but most will work using the cut/paste keys located on the left-hand side of the keyboard. Also, the results of various S-Plus operations can be pasted into documents that can be printed or saved.
Graphics and Printing
To open a graphics window in S-Plus type ...
X11()
This window allows you to view the plots created by S-Plus and to print these graphics.

See the S-Plus documentation for the commands relating to various plots available. To see, however, a sample plot enter ...

plot(corn.yield)
Here is an example of plotting some sample data:
x<-c(10, 20, 40, 50)
Here you are collecting these values and calling them "x."
y<-c(17, 19, 25, 37)
Here you are collecting these values and calling them "y."
plot(x,y, xlab="One", ylab="Two")
title("My Plot")
This adds a title.
There are many ways of modifying your plots using S-Plus. You should become aware of the additional plot commands such as lty, sub, pch, type.

To print the resulting graphic you need to enter some new values into the existing window. Where the print destination is shown replace this path with ...

qpr -q  geogbw1
Select the print button and an output (reverse black/white) will print on the lab laser printer.
S-Plus Commands
Clearly there are a host of commands that can be used in the S-Plus software to achieve specific outcomes. To get you started, here are some commonly used commands that help you the user manipulate and interpret your data.
lines
points
rep
sort
cbind
mean
median
stem
range
length
var
pairs
summary
help
Additional Documentation
The UNIX lab has a number of guides for the S-Plus software. Besides the required The New S Language text check out:
S-Plus Users Manuals 1 & 2
S-Plus Reference Manuals 1 & 2
Statistical Models in S
Programmer's Manual
Supplement to 3.1 Version