S+ 6.1 for Windows
- To Start S-Plus:
- Click the S-Plus Icon
in the Statlab Packages > S-PLus 2000 folder.
You will see a Select Data dialog box: the various options are described in the Entering Data section below. You will probably want to enter New Data or use the Import File command.
- To Exit S-Plus:
- You can either type q() in your command window, or use the File > Quit menu option.
- Entering S-Plus Commands:
- -- The simplest way to issue a command is entering it at S-Plus' prompt, >, in a command window, obtained by selecting the Window > Commands Window menu option. If you want to use or modify a previous command, you can scroll through the most recent commands using the up and down arrow keys. You can also cut and paste (using either the buttons or the Edit menu options.
- -- If you are working on a program with more than a few commands, open a script window using the File > New menu. You can type a series of commands here and save them to script files (*.SSC) or execute the commands. To execute the whole script, you can click on the run button (lower left of the tool bar when you're in the script window). To execute a few commands, you can highlight the commands you want before clicking the run button.
- To save your output:
- Go to the Options > Text Ouput Routing menu and send the ouput to a report file. You can also cut and paste output from the Commands window. The report window will allow you to edit the results and insert any comments. This window can be saved to a floppy or printed.
- To print a graph:
- Click in the graphics window, then use the File > Print Graph Sheet menu option.
- Entering Data:
- Upon starting S-Plus, a Select Data menu will prompt you for three primary methods of entering data: (1) use Existing Data only if you used the machine previously and if the data objects still exist; (2) use New Data to enter new data in a spreadsheet-type interface; and (3) use the Import File command to read data from a file. This latter option also appears in the File menu, and is described at the bottom of this section. Other methods, using the Commands Window, include:
- v<-scan()
- You are prompted to enter your numerical data, finish with hitting twice. Data are stored in a vector "v".
- scan("c:\\user\\mydata")
- Imports numerical data (separated by blanks) from the file "mydata". Use "\\" in the path, as the backslash is a special character in S-Plus!
- m<-matrix(scan(),byrow=T,ncol=3)
- Creates a matrix "m" with 3 columns, data are entered by row.
- scan("mydata",what="")
- Reads data in character mode.
- read.table("mydata")
- Creates a data frame from a table "mydata" which contains numerical and text data. If you don't supply row names the first column containing characters is taken for row names.
- source("dat.sp")
- Reads S-Plus data created with dump() .
- data.restore("dat.sp")
- Reads S-Plus data created with data.dump().
- File > Import Data > From File
- Opens a dialog box which allows you to browse through files and choose options. In the File name box choose the file containing the data; note that the File type option directly below can help you choose between input files of different types (e.g. ASCII, Excel, SAS...). You should specify the Import to Data Frame label as well. Various other options, including choice of delimiter for ASCII files and specifying use of variables names in the first row(s) of the data file, are available under the Options tab.
- Write Data to an ASCII File:
- write(t(m),"m.dat",ncol=ncol(m))
- Writes the data of matrix "m" into an ASCII-file "m.dat". To get a row by row output, the matrix must be transposed with the t() .
- dump(c("m","x","y"),"a:\\dat.sp")
- Writes the objects m, x, and y and the appropriate S-Plus to an ASCII-file, a:\dat.sp (for transfer to different users or machines). Read in with source() .
- data.dump(c("m","x","y"),"dat.sp")
- Essentially the same as dump(c("m","x","y"),"a:\\dat.sp") but somewhat faster. It is only meant to be read by the S-Plus command data.restore("a:\\dat.sp").
- Examples on the Statlab NT server:
- i:\Workshop\lesson1.ssc
- A script file that contains examples of the different data types (vectors, matrices, lists, factors, etc.)
- i:\Workshop\Bears.ssc
- A script for doing a multiple linear regression with the data from the i:\Workshop\Bears.xls data set. You will need to use File > Import Data > From File to import the data as a data frame called Bears.
- i:\Workshop\gunanova.ssc
- An example of analysis of variance using formulae with multiple interaction terms.
For help moving from older versions of S-Plus see: Information about moving from old versions of S-Plus
lm: September 20, 2001
