S-PLUS Online User's Guide

Bret Larget

Duquesne University

September, 1999

Answers to questions


How do I log on to the Computer?

You will need a computer account from the Department of Mathematics and Computer Science provided by your instructor. You will need to know your login name (most likely your last name or a variation) and your password. This information is on an account sheet you receive from your instructor. This sheet also details how to change your password.

If you had an account previously, your account (and the password) will be identical to what they were in the past. If you do not know your previous password, see Professor Larget and he will create a new password for you.

The computers should always remain on. First try pressing the shift key to ``wake up'' a computer that is in stand-by mode. The green indicator and the power button for the monitor are near the lower right side of the screen.

After checking the monitor is powered and giving it a few moments to wake up, you should see a prompt asking you for a login name. After entering your login name and pressing the Enter key, enter your password (and Enter) as prompted. After a short while, the screen will turn blue and a number of icons and windows may appear. The computer is now running UNIX. To use the statistics software, you will need to reboot the machine under Windows 95.


How do I exit from UNIX?

With the mouse, move the cursor to any part of the blue background, press and hold the RIGHT mouse button, and select exit from the pop-up menu. Confirm by clicking with the left mouse button.


How do I start Netscape under UNIX? There is more than one way to do this, but here is the easiest. Using the mouse, position the cursor (the arrow) in the blue background. Press and hold the right mouse button. This opens a pop-up menu. Move the arrow to Programs, slide it to the right to open a submenu, slide it down to Netscape... and release the button. In a few moments, the Web browser Netscape will start. (If you're prompted about a license, click on AGREE.)
Where are the on-line course materials?

The quick answer is http://www.mathcs.duq.edu/larget/math225/math225.html for Web experts. More detail for Web novices is below.

You may access the course materials from your math/cs account on a lab computer or from any other computer on campus or at home connected to the campus network. If you're in the lab, pressing the home button at the top of the Netscape window should bring you to the Math/CS Department homepage. Below the picture of the department chairman is a box which says Mathematics Faculty. Click on the gothic D to go to the list of mathematics faculty. Scroll down to the assistant professors where you will find a truly awful bleached out picture of Professor Larget's face. Click on it. This action brings to the screen a larger, more blurry picture of Professor Larget. Quickly click on courses to make it go away. Finally, click on Math 225, Introduction to Biostatistics to find the course notes.

You can open the Bookmarks menu and select ``Add Bookmark''. Next time you connect, you can go directly to this page from the Bookmark menu.


How do I start Windows 95?

After logging in and starting UNIX, move the cursor to an open spot in the blue background, press and hold the right mouse button, move down to Windows..., and release the button. Ignore the horror message about the world ending in 15 seconds, and wait about half a minute until the computer shuts down and starts up Windows 95.


How do I start S-PLUS?

From Windows 95, there should be an icon that says S-PLUS 4.0 (or possibly S-plus~1 if the computer is in a bad mood). Double click on it to start the software.

When you start S-PLUS, there should be a menu bar across the top of the screen, a ruler with several buttons, and two windows open below. One window, called an object browser, has a list of data sets for the class (and other things). The other window is a command window, where an expert can type commands. If you click on a menu item, you can read the choices. If you hold the arrow over a button for a few moments, a small box opens telling you what the button does.


What is S-PLUS?

S-PLUS is a powerful statistics package which was developed for use in statistical research. Older versions required knowledge of a complicated computer syntax. This version allows novices to do most tasks with simple point-and-click from menus. Experts can still execute more advanced commands by typing in the command window. For this course, you will use, almost exclusively, point-and-click commands. You will need to learn how to use the software to complete some assignments, but will not be tested on its use. You will be responsible on examinations with knowing how to interpret output from the software.


How do I quit Windows?

The machines in the multi-media classroom and in the Alcoa Computer Lab should not be turned off. To quit, click on the Start button and select Restart the computer.


Managing data

How do I load in a data set from the class Web page?

  1. Start Netscape from Windows and open up the course Web page.
  2. Click on the data set you want.
  3. From the File menu, select Save As...
  4. Select the Desktop (or another desired location) as the location to save the data and click on Save.
  5. Quit or minimize Netscape.
  6. Start or maximize S-PLUS.
  7. From the File menu, select Import Data and then From File....
  8. Find the data set where you saved it. You may need to change directories by changing the ``Look in'' information. You will also need to change the ``File type'' information to text files (*.txt).
  9. Click Okay

How do I import data from a floppy or some other file?

Under the file menu, select ``Import Data'', and then ``From File...''. Use the little down arrow in the ``Look in'' box to find where your data is and then press the open button.


How do I enter in a small data set directly into S-PLUS?

Follow these steps to create a variable named deathTime with the data

44 27 24 24 36 36 44 44 120 29 36 36 36

  1. Open a Commands Window by clicking on the button with the ">x" symbol if you do not already have one open. [How?]
  2. In the Commands Window, create a variable called deathTime using the scan function. You can put spaces or single carriage returns between numbers. A carriage return on a blank line ends the input. See the example below. (Some of the characters below are computer output.)

    > deathTime <- scan()
    > 1: 44 27 24 24 36
    > 6: 36 44 44 120 29
    > 11: 36 36 36
    >
    


How do I enter in a data set from an Excel spreadsheet?

The answer to this fine question is not yet documented here. Try either the help menu in S-PLUS or ask Professor Larget in person.


How do I delete a data set?

The answer to this fine question is not yet documented here. Try either the help menu in S-PLUS or ask Professor Larget in person.


How do I look at the data in a data set?

The answer to this fine question is not yet documented here. Try either the help menu in S-PLUS or ask Professor Larget in person.


How can I refer to the variables in a data frame by name?

In the Command Window, type

> attach(x)
to be able to refer to the variables in the data frame x by name.


Managing the windows

How do I make a window active?

Only one window is active at a time. Clicking anywhere in the window will activate it. You can also select the window from the window menu. This is especially helpful if the window is buried by other windows or minimized.


How do I make a window go away?

Each window has three little buttons in the upper right corner. The first button will minimize the window and turn it into an icon at the bottom of the screen. (The icon may be buried by other windows.) Clicking the left button on the icon opens it again.

If you want to close a window for good (typically a graph or a report you don't need anymore), click on the third button with the ``x''. When you are prompted if you want to save changes, say no.


How do I make a window bigger?

The middle button on the top right will maximize a window. If a window is already maximized, the middle button returns it to normal size.


How do I make a graph bigger?

When the graph window is active, pressing the ``F2'' function key will display the graph full screen. Pressing the ``F1'' function key returns the graph to its previous size. You can also use the second maximize button which makes the graph bigger without covering the menu bar or ruler.


How do I organize my windows?

The Window menu has many tools. Tile vertical is my favorite choice to show all open windows. You can also bring a buried or iconified window to the front from this menu.


How do I open a Commands Window?

Open the command window in S-PLUS. This window has a prompt that looks like this ``>''. You can open the command window by opening its icon or from the Windows menu. Also, there is a button on the task bar to open a command window.


Exploratory data analysis

How do I make a histogram?

There are multiple ways to make histograms in S-PLUS. This is the simplest.

  1. Click on the ``2D Plots'' button, which is on the ruler and has a small picture with a bar graph and a jagged line. This opens up the Plots2D palette.
  2. Click the histogram button which has a picture of a little histogram. A graphics window and a dialog box will open.
  3. Click the little arrow next to ``Data Set'' and then click on the name of the data frame where your variable is.
  4. Click on the little arrow next to ``x Column(s)'' and then click on the name of the variable.
  5. Finally, click on the OK button.

If you want to change the bin size or customize the histogram in other ways, click on the ``Options'' tab and make changes before clicking on OK.

Alternatively, you can make histogram directly from the Command Window. To make a histogram of the data in x (either a vector or the variable name of an attached data frame) type into the command window

> hist(x)


How do I make a stemplot?

The answer to this fine question is not yet documented here. Try either the help menu in S-PLUS or ask Professor Larget in person.


How do I make a boxplot?

Just like with histograms, click on the ``2D Plots'' button. The box plot button is in the middle column of the Plots2D palette, six from the top. Click on it. Choose the data set just as you did for histograms. Because the variable will be drawn on the $y$-axis, click on the arrow to the right of ``y Column(s)'' and select the variable you want.


How do I make side-by-side boxplots?

These plots are most useful when you want to examine a quantitative variable separately for each category in some categorical variable. Open the ``Plots2D'' palette, select the data set, put the categorical variable in for ``x Column(s)'' and the quantitative variable in for ``y Column(s)''.


How do I calculate summary statistics such as means, standard deviations, and quartiles all at once?

  1. From the statistics menu, select ``Data Summaries'' and then ``Summary Statistics...''.
  2. Choose the data frame and click on or off any statistics you wish to see. You can do all variables simultaneously or one or several at a time. click on an individual variable to do only one.
  3. Clicking on a second variable while holding the shift key allows you to see summary statistics for all variables between the two. A report sheet opens with the summary statistics.


How do I calculate the mean of a variable from the command window?

The following commands find the mean, median, minimum, and maximum of a variable x.

> mean(x)
> median(x)
> min(x)
> max(x)


How do I find the five number summary?

The command name is quantile. By default, it will find the minimum, lower quartile, median, upper quartile, and maximum of a variable.

> quantile(x)


How do I find an arbitrary quantile?

The command name is quantile. If you wanted to find the 85th percentile of a variable x, you would type

> quantile(x,.85)

To find the lower quartile, you could type

> quantile(x,.25)


Random Samples

How do I reset the random seed?

Type set.seed(n) in the command window where n is a nonnegative integer.


How do I take a random sample from a variable in a data frame?

First, make sure the data frame is attached. The command sample takes a random sample with or wihtout replacement.

Examples:

> sample(x,10)
randomly selects 10 elements of the object x without replacement.

> sample(x,10,replace=T)
randomly selects 10 elements of the object x with replacement.


Last modified: August 25, 1999

Bret Larget, larget@mathcs.duq.edu