Appendix C: Alphabetized List of Most Important Functions In S-Lab

(You can learn more about these by typing help(function name)
or ex(function name))

anova(out)                  gives ANOVA table of output from lm
arithmetic
    a+b                     add a and b
    a-b                     subtract b from a
    a*b                     multiply a times b
    a**b or a^b             raise a to bth power

bplot(x)                    boxplot of x
c(4,2,9)->z                 creates vector z with values z[1]=4,z[2]=2,
                            z[3]=9
c(x,y)->z                   combines x and y into long vector z
cbind(x,y)                  combines n by 1 vectors x and y into n by 2
                            matrix z
count(x>0)                  counts number of elements of x which are > 0
count(x==0)                 counts number of elements of x which are = 0
data.frame(x,y)             creates data frame from x and y

dbinom(x,N=20,p=.7)->y      evaluates binomial prob. function at x
dexp(x,beta=3)->y           evaluates exponential density with mean=3 at x
dgam(x,alpha=2,beta=3)->y   evaluates gamma density at x
dnorm(x,mean=2,sd=3)->y     evaluates normal density at x
dunif(x,min=5,max=20)->     evaluates uniform density on (5,20) at x
dweib(x,alpha=4,beta=2)->y  evaluates Weibull density at x

ex(plot)                    gives examples for many functions
help(plot)                  gives information about any function
hplot(x)                    histogram of x
lines(x,y)                  add lines to existing plot
lm(y~x,data=z)->out         linear model of z$y=intercept+(beta)(x)
log(x)->y                   puts natural logarithm of x into y
log10(x)->y                 puts base 10 logarithm of x into y
lplot(x,y,z)                plot allowing character variables and optional
                            labeling of point by z
means(y,x1,x2,..)           analysis of means of y for factors x1, x2, ...
mean(x)                     returns mean of x
mplot(y,x1,x2,..)           means plot of y by factors x1 and x2
names(x)                    gives names of vectors in x
 c("first","sec")->names(x) gives names "first" and "sec" to x with 2
                            columns. Use after read.table.
plot(x,y)                   scatterplot of x and y
pnorm(x,mean=2,sd=3)->y     evaluates normal distribution function at x
                            see also, dnorm, rnorm, qnorm, and dbinom,
                            dexp, dgam, dunif, dweib, etc.
points(x,y)                 adds points to existing plot
qnorm(p,mean=2,sd=3)->y     gets pth quantile of normal distribution
                            see also dnorm, pnorm, rnorm, etc.
read.data()->y              type in data set to y
read.table("your.data")->y  read ascii file your.data into y, variable
                            names are y$V1, y$V2, ... by default
rnorm(50,mean=2,sd=3)->y    puts 50 random normal variables in y
sd(x)                       gives standard deviation of x
seq(2,5,,20)->x             vector x of equally spaced points in (2,5)
set.panel(3,2)              Sets plot window to make panel of 3
                            rows of 2 graphs
simulate.samples(50,5,      simulate 50 samples of size 5 from
DIST=rnorm,mean=2,sd=3)->y  a normal dist., sample means and std's in y
source("sn")                executes S commands in Unix file sn
sqrt(x)->y                  puts square root of x into y
stats(x)                    summary statistics for x
stem(x)                     stem and leaf plot for x
sum(x)                      sums up values of x

  if lm(y~x1+x2,data=z)->out
summary(out)                regression summary of lm output
title("Y versus X")         add title to existing plot
xline(0)                    add vertical line at x=0
yline(0)                    add horizontal line at y=0