SOME S-PLUS BASICS AND COMMONLY USED COMMANDS
=============================================


A.  STARTUP AND ENVIRONMENT 

	Splus				to start up the Splus system
	motif()				to open a graphics window for plots on screen
	help.start()			to open the help window system
		or you may need to use help.start(gui="motif")

B.  INPUT AND OUTPUT 

	x _ scan("filename")		  to read numbers from a file
	x _ read.table(file="afilename")  to read a table (matrix) of data
	source("sfile.s")		  to read Splus code from a file
	sink("file")			  to write everthing that follows to a file
	sink()				    .. and back to the screen
        write(..)			  write to file -- check help
	write.table(..)			  write to file -- check help 	


C.   ORGANISING DATA

        x _ matrix(x,ncol=5,byrow=T)	reorganises data in x to a 5 column matrix
	x _ matrix(x,12,5)		reorganises data in x to a 12x5 matrix, by column
	x _ matrix(scan("filename"),12,5) etc
	x _ c(x,c(1,10,y),1:10)		c() means "catenate" to create vectors 

D.   RANDOM VARIATE GENERATION AND DISTRIBUTIONS

	sample			  to sample with or without replacement from a set

	dnorm()			  normal pdf
	pnorm()			  normal cdf
	qnorm()			  normal quantile function, inverse of pnorm()
	rnorm()			  generate normal random variates


	Others: ?dist where ? =d,p,q,r with parameters as follows: 

     |+--------------------------------------------------------------+|
     ||  dist         Distribution       Parameters        Defaults  ||
     |+--------------------------------------------------------------+|
     ||  beta         beta             shape1, shape2        -, -    ||
     ||  cauchy       Cauchy           loc, scale            0, 1    ||
     ||  chisq        chi-square       df                    -       ||
     ||  exp          exponential      -                     -       ||
     ||  f            F                df1, df2              -, -    ||
     ||  gamma        Gamma            shape                 -       ||
     ||  norm         normal           mean, sd              0, 1    ||
     ||  t            Student's t      df                    -       ||
     ||  unif         uniform          min, max              0, 1    ||
     |+--------------------------------------------------------------+|

E.   PLOTTING

	par(mfrow=c(3,2))		6 plots laid out in 3 rows of 2
	par(....)			many arguments to control display, such as
			mfrow=c(1,1)	plot layout on screen/page
			bty="n"		no frame drawn around graph
			and see help for others

	hist(x,nclass=25,prob=T)	histogram
	plot(x,y)			scatter plot
	plot(x,y,type="l")		line plot 
	plot(x,y, ...)			many arguments to control display, such as
			type="l"	for lines
			xlim=c(0,10)	range of plot on horizontal axis
			ylim=c(0,1)	..
			xlab="here is a label on the x-axis"
			ylab=..
			col=2		use second colour
			lty=3		use third (broken) line type
			lwd=2		twice the usual line width
        lines(x, y)			add lines to a plot
	points(x, y)			add points to a plot

	tsplot(x)			Plots a vector vs 1,2,....	
					(time series plot) 
        qqnorm(x)			normal quantile plot
        boxplot(x, ..)			boxplot

        mtext(side=3, line=0, cex=2, outer=T,
	      "This is an Overall Title For the Page")

F.   ASSIGNMENT AND BASIC ARITHMETIC OPERATORS

     <- or _  Assignment 
	 *    Multiply				
	 +    Add				
	 -    Subtract				
	 /    Divide
	 ^    Exponentiation

G.  SEQUENCE AND REPETITION 

	 x_ 1:50
         x _ seq(1,50,by=10) 
         x _ seq(1,50,length=50) 
	 x _ seq(0,1,length=100) 
	 x _ rep(y,10) 	

H.  SUBSCRIPTS

	 [ ]	Vector subscript		x[3]_101;  y _ x[20:1]+1
	 [,]    Matrix subscript		x[1,5]_0;  y[1:10,]

I.   RELATIONAL OPERATORS

	 ==   Equal-to
	 !=   Not-equal-to
	 <    Less-than
	 <=   Less-than-or-equal-to
	 >    Greater-than
	 >=   Greater-than-or-equal-to


J.   CONDITIONALS

        if (i==1) x_10 
	if (i>0) { x_10; y_20} 
		 else  x_y_0

K.   ITERATION
	for (i in 1:10)  { x[i]_i; y_c(i,y); ... } 

L.  ARTIHMETIC OPERATORS AND FUNCTIONS

	 abs(x)
         cos(x), sin(x), acos(x), etc 
         exp(x)
         gamma(x)
         log(x)
         log(x, base=exp(1))
         max(...), min(...)		    
         mean(x)
         median(x)
	 mode(x) 
	 summary(x) 
         quantile(x, probs=c(0,.25,.5,.75,1))
         sum(...)
         var(x,y)
	 cor(x,y)