Skip to Content

College of Arts & Sciences
Department of Statistics


Using PCs

In addition to the individual graduate student offices, PCs can be found in rooms 124 and 303A of LeConte during regular business hours. If a staff member arrives to lock the lab at the end of the business day you must leave, NO EXCEPTIONS, including faculty members. You may re-enter later if a faculty member opens the door for you and takes responsibility for the lab. All of these machines will have Microsoft Word, Excel, SAS, Minitab, and R. Half of the PCs in room 102 PSC (Physical Sciences Building) are also equipped with SAS. That lab typically has longer hours.

These machines are on the MATHSTAT domain, and your accounts on these machines are separate from your accounts on the UNIX machines. You will therefore need to remember the possibly different passwords and login names (the MATHSTAT login name will be the same as the one you find under the TECHNOLOGY link at VIP, the password will not necessarily be the same). To get a login screen to appear, if the computer is on, simply hit the Ctrl, Alt, and Delete keys simultaneously (you will need to make sure that the domain is sat to MATHSTAT and not to administrator). This will also let you logout later, or kill any hung programs.

Each account has storage room on the Z drive. In most cases this is where you should store your files. You will generally not have access to installing new software on the machines C drives.

R is a free statistical package based on the same underlying language (S) that S-Plus is. It can be downloaded from www.r-project.org [At home, after reading the instructions!, choose: CRAN, then Download R for Windows, then base, then the .exe file].

One of the nice things about the statistical package R (besides the fact that it's powerful and free) is that you can save everything you've done after you've finished each time. Since you don't have access to the C drive on your accounts, you will need to manually load and save the .Rdata file in your Z drive each time you want to start and end the program, respectively.

Once you know the name of a function, you can get help about it simply by typing help(functionname). In R, parentheses indicate either mathematical grouping, like they usually do, or that you are applying a function. Braces [ ] indicate that you are finding an element in a string.

This brief example shows some of R's flexibility.

ex3<-c(0,2,1,2,3,4)

This first line simply enters a sample data string "ex3". (Why ex3? it needed some name! If you don't like it, choose another.) No output should appear on the screen. Entering the following lines one at a time will give: the mean of x, the third element of x, the values of x in order, a qqplot of x, and the line for the qqplot.

mean(ex3)
ex3[3]
sort(ex3)
qqnorm(ex3)
qqline(ex3)

The following code enters a function that draws the empirical distribution function for any string given to it. After a while, you should be able to follow through most of the commands. The type="n"in the first plot command says to just draw the axes and no values. The lines command gives the two x coordinates and then the two y coordinates. The first lines segment goes from 1 less than the smallest x to the smallest x, with the y values not changing at all.

edf<-function(y){
x<-sort(y)
plot(c(min(x)-1,max(x)+1),c(0,1),type="n",xlab="x",ylab="p")
lines(c(x[1]-1,x[1]),c(0,0),lty=1)
lines(c(x[1],x[1]),c(0,1/length(x)),lty=2)
for (i in 1:(length(x)-1)){
lines(c(x[i],x[i+1]),c(i/length(x),i/length(x)),lty=1)
lines(c(x[i+1],x[i+1]),c(i/length(x),(i+1)/length(x)),lty=2)}
lines(c(x[length(x)],x[length(x)]+1),c(1,1),lty=1)
}

edf(ex3)

We could use this function to compare the edf of a sample of size 10 from normal and one of size 30 from a chi-squared populations.

x<-rnorm(10,mean=0,sd=1)
y<-rchisq(30,df=10)
par(mfrow=c(2,1))
edf(x)
edf(y)

Help will tell you what rnorm and rchisq do. The row with partells the computer to disply the output in 2 rows and 1 column.

Some other S-Plus commands are: var, cor, lm, hist, plot, t.test, prop.test, and var.test. There are literally hundreds of others. A good reference is Modern Applied Statistics with S-Plus by Venables and Ripley (published by Springer).

Using R Packages on MATHSTAT: One feature that R has is the ability to download extensions directly from on-line through the Packages menu. The difficulty with using the Install package from CRAN... option in this menu is that you generally will not have appropriate access when you are on a CSM domain computer. (This is not a problem for several of the built in libraries like MASS.... all those listed in the Load package... list.) The following instructions demonstrate how you can install the package tree on your Z drive and then call it up later.

Start up internet explorer and go to the page
http://cran.r-project.org/bin/windows/contrib/1.9/
and choose tree_1.0-18.zip

When it asks you what you want to do with the file...
* select "Save this file to disk"
* choose your Z drive and save it there

On the next box that comes up, select "Open Folder" and select "tree_1.0-18.zip"

It should now automatically open WinZip...
* Choose "Extract"
* Highlight the Z drive so it shows in the window in the upper left
* Extract
* Choose Exit in the File Menu

Following the above commands should put a copy of all the needed code into a directory on your Z drive.
From now on all you need to do to get the trees functions are to use the following two lines

 

library(tree,lib.loc="z:/")
library(help=tree,lib.loc="z:/")

The following commands will perform a regression tree analysis on a portion of the Bumpus sparrow data:

 

bumpus2<-read.table("http://www.stat.sc.edu/~habing/courses/data/bumpus2.txt",header=TRUE)
library(MASS)
bumpus2[,1]<-as.factor(bumpus2[,1])
b.tr<-tree(survive~length+alar+weight+lbh+lhum+lfem+ltibio+wskull+lkeel,bumpus2)
summary(b.tr)
plot(b.tr)
text(b.tr)
predict.tree(b.tr)

Graphics in Word: It is possible to cut and paste graphics images from programs like SAS, R, and web-stat directly into your Microsoft Word documents. To copy a graphic from R, simply right click on the image and choose "Copy as bitmap". To copy a graphic from SAS, select the desired image and copy it just like it was text in any other program. An image on the screen can always be captured using Ctrl-Alt-PrintScrn. To paste the image into word simply use "Paste" from the "Edit Menu".

To make it so that you can move the image around the page, right click on the image and choose "Format Picture...". Under the "Layout" tab choose "In front of text."

If the fonts in your image (especially from SAS) do not quite look right, right click on the image and choose "Edit Picture" (or "Open" in the "Picture Object" menu). This will open the image up in a new window. Simply choosing "Close Picture" (or "Close & Return" in the "File" menu) will then close the image after automatically adjusting the fonts. This will often correct the problem of SAS images printing out at microscopic size.

Alternative Method of Copy/Paste from Minitab: If you have trouble copying and pasting from Minitab into other applications, follow these steps:

  1. Select the graph you wish to copy, the click on File->Save Graph As
  2. Navigate to where you would like your graph saved
  3. In the Save as type: box, select Windows BMP Color
  4. In the File name: box, name your graph and add .bmp at the end
  5. Click Save
  6. Now, your graph can be inserted into your application. In Word, this is done with Insert->Picture->From File... and then locating your graph where it was saved in the previous step.

Fortan 77 / C++ Compiler: Both Fortran and C compilers are available on our Unix network... but that requires you to use Unix. You can have the MinGW suite installed on your PC by e-mailing help@stat.sc.edu and asking them to install it on your PC using the instructions at http://www.stat.sc.edu/~habing/courses/740/mingw.html. Make sure to tell them your room number and computer name (e.g. LC084 or whatever).