S.notes yandell 29 sep 1994 This file will be updated occassionally with tidbits about S. Best that you read it here rather than copy it to your directory. SAS is only available on the "atlas" computer. S LIBRARY ACCESS S is available on "atlas" and "bayes". Splus is only available on "atlas". The S function "library()" can attach a library of functions and/or data to enhance the S system. For instance, > library(data) attaches the datasets used in the "Statistical Models in S" book (the functions are already attached). The command > library(pda) attaches my "Practical Data Analysis" library of routines. The command > library(help="pda") will show you a brief synopsis of pda commands available. Some commands have help pages. For instance, try > help(lsd.plot) The command > search() shows what directories you currently search for functions and data. Normally you need not check this. However, it can tell you which frame contains pda. CHANGING PLOT AXES You can turn off an axis with the "xaxt" or "yaxt" option (see "par()"). Then you can manually but text and/or axes with "mtext()" or "axis()". > plot(1:10,1:10,xaxt="n") > ?par ... [lots of lines of explanation of plot options!] xaxt="c" axis type. Type "n" (null) can be used to cause an axis to be set up by a high-level routine, but then not plotted. Values "s", "t", and "l" mean that the axis is standard, time, or logarithmic, respectively. However, it is difficult to change xaxt to anything other than "n" since xaxp parameters must be kept consistent with xaxt. ... > mtext(c("a","b","c"),1,1,at=c(2,5,7)) > ?mtext Text in the Margins of a Plot USAGE: mtext(text, side=3, line=0, outer=FALSE, at=) ARGUMENTS: text: character vector to be plotted. side: side (1,2,3,4 for bottom, left, top, or right). line: line (measured out from the plot in units of standard- sized character heights). The default values of graphical parameter mar allow characters can be placed at values of line less than or equal to 4 on the bottom, 3 on left and top, and 1 on the right. outer: logical flag, should plotting be done in outer margin? at: optional vector of positions at which text is to be plotted. If side is 1 or 3, at will represent x- coordinates. If side is 2 or 4, at will represent y- coordinates. at can be used for constructing specialized axis labels, etc. > axis(1,at=c(1,3,9)) > ?axis Add an Axis to the Current Plot USAGE: axis(side, at=, labels=TRUE, ticks=TRUE, distn=, line=0, pos=, outer=FALSE) ARGUMENTS: side: side of plot for axis (1,2,3,4 for bottom, left, top, right). at: optional vector of positions at which the ticks and tick labels will be plotted. If side is 1 or 3, at represents x-coordinates. If side is 2 or 4, at represents y- coordinates. If at is omitted, the current axis (as specified by the xaxp or yaxp parameters, see par) will be plotted. labels: optional. If labels is logical, it specifies whether or not to plot tick labels. Otherwise, labels must be the same length as at, and label[i] is plotted at coordinate at[i]. ticks: if TRUE, tick marks and axis line will be plotted. ... PLOTTING TEXT INSTEAD OF POINTS The commands "mplot()" and "mpoints()" are short routines I wrote. They are part of pda. They use the "text()" command. > mplot(1:10,1:10,pch=letters[1:10]) > ?mplot No documentation available for mplot > mplot function(a, b, pch, xlim = range(a), ylim = range(b), xlab = deparse(substitute( a)), ylab = deparse(substitute(b)), main = "", ...) { plot(a, b, type = "n", xlim = xlim, ylim = ylim, xlab = xlab, ylab = ylab, main = main, ...) mpoints(a, b, mch = pch, ...) } > text(1:10,10:1,labels=LETTERS[1:10]) > ?text Plot Text USAGE: text(x, y, labels=seq(along.with=x), cex=, col=) ARGUMENTS: x,y: coordinates of points. The coordinates can be given by two vector arguments or by a single argument x which is a time-series, a complex vector, a matrix with 2 columns, or a list containing components named x and y. Missing values (NAs) are allowed. Labels are not plotted at any point with a missing x or y coordinate. labels: normally, labels[i] is plotted at each point (x[i],y[i]). However, if labels is a logical vector of the same length as x and y, the value i is plotted at each (x[i],y[i]) for which labels[i] is TRUE. Missing values (NAs) are allowed. ...