S Poetry



S Poetry was written when R was in its infancy, and version 4 of the S language was not yet publicly available. There have been a number of changes since then.

If you are using R, probably the best way to figure out what is not right in S Poetry is to read about the differences between R and S in the R FAQ (ISBN 3-901167-51-X) on the R Project Home Page .

If you are using S-PLUS, almost everything is still true (except some of the bugs are fixed). However there are some new features that are useful -- the release notes for S-PLUS will highlight some of them.

Contents

Overview

Getting It

R Packages

Chapter Descriptions

S Functionality

Overview

S is the language that underlies S-PLUS (sold by Insightful ) and the R language -- an open source version available from the R Project. The tutorials area includes a non-technical introduction to the S language, and "A Guide for the Unwilling S User" -- a brief document to help new users get started using S productively.

S Poetry is a book that is geared towards those who plan to program in S. However, there are some parts that can be of use to others:

  • The glossary explains words that involve computing and statistics as well as S. It can be useful to someone who knows one subject, but not the other. Also it is useful to those who know both subjects, but for whom English is not a native language. Emphasis is put on words that have more than one meaning.
  • The first chapter, called "Essentials", gives a grounding in the language and is of interest even to those who don't envision themselves programming.
  • In addition, there is a collection of S functions and other objects. These offer functionality that can be of interest even if you don't care about the book.
Getting It

You can get the following in pdf format:
S Poetry (whole book which includes the glossary, 439 pages, 1M)
The glossary (38 pages, 180K)
The Essentials chapter (22 pages, 125K)

Adobe Acrobat reads "pdf" files. You need Acrobat to read these pdf files. If you don't have it, you can get it free. See Adobe Acrobat.

A shar file of S functions, help files and objects that goes with the book is poetry.shar (250K). (It is my understanding that you probably want to get this as binary rather than text to avoid the tab characters in the Makefile being converted to spaces.) Shar files are a Unix way of putting a number of files into one file so that they can be transported as a whole. If you do not have the capability to unpack shar files, you can still get the file and extract pieces that you want with an editor.

A file of just the code for "genopt" is genopt.R

The book is available to be used and distributed. Organizations may make as many copies as they like for internal use and to give away at no charge. It is also acceptable to charge a nominal amount for copies to cover the cost of the medium. Please be environmentally friendly by using paper wisely.

R Packages

The following R packages are not products of Burns Statistics.

Nick Efthymiou (nick.efthymiou at schwab.com) has written and will maintain two R packages based on functions from S Poetry.

mathgraph package


Functions implementing a class for mathematical graphs, and a few miscellaneous functions.

mathgraph_0.9.tar.gz (gzip of tar file of the package)
mathgraph.pdf (compilation of the help files)


verify package


The verify family of functions for implementing test suites.

verify_0.9.tar.gz (gzip of tar file of the package)


To install a package in Linux or Unix, you can issue a command like:

R CMD INSTALL mathgraph_0.9.tar.gz

You will probably need system administrator privileges. The process on Windows is very similar. The command to use might be something like:

Rcmd INSTALL --doc normal mathgraph_0.9.tar.gz

This is done in a command prompt window, and assumes you have the appropriate tools installed.

Chapter Descriptions

A synopsis of each chapter follows.

1. Essentials

Introduction to the basics of the language, and some indication of why they are important. Includes a full description of subscripting.

2. Poetics

An attempt to convey an understanding of good style in S (and elsewhere).

3. Ecology

How to interact with S peacefully. This includes test suites, source code control, and time and memory monitoring. Much of the code of this chapter does not pertain to R, though the concepts do.

4. Vocabulary

The functions that are most important to know.

5. Choppy Water

Spots that are particularly confusing when programming in S. This is fairly dated now, but some of this chapter remains true.

6. Debugging

The title pretty much says it, how to debug in S. Has suggestions on what to include when asking questions on S-news or R-help.

7. Unix for S Programmers

Handy things to know about Unix (including Linux) if that is your operating system.

8. C for S Programmers

Writing C code that is called by S. A token nod is given to Fortran. This highlights similarities and differences between S and C, so C programmers wanting to learn S can benefit from this chapter.

9. S for S Programmers

Everything you are afraid to ask about S.

10. Numbers

Examples of functions dealing with numbers. Includes functions for: changing the base of numbers (integers only), working with rational numbers, computing the polygamma functions, computing the digamma function (complex numbers allowed), and using continued fractions.

11. Character

Examples of handling character data. Includes a simple (but powerful) interface to the Perl language, and a function to justify a vector of character strings.

There have been some major improvements in the language since this was written. In particular the regexpr function is very powerful.

12. Arrays

A little on how to work with multidimensional arrays.

13. Formulas

Using formulas in S. The major example here is a suite of functions for mathematical graphs.

14. Functions

Examples of functions that concern other functions. Functionality includes: numerical integration in the complex plane, creating functions that perform Lagrange interpolation, a simple (but effective) genetic algorithm, and creating functions that optimize a function written in C or Fortran.

15. Large Computations

A few words on doing computations that consume either a lot of time or memory.

S Functionality

The collection of functions has those described above in chapters 10 through 14. It also contains functionality from the earlier chapters. Some highlights are: functions for source code control, writing test suites, and time profiling. Some functions that are not from S Poetry are available in the public domain code area.

Here is a list of the S functions in the shar file (see also R Packages above). A brief description is given for the more interesting ones.

*.rationalnum -- Multiplication for rational numbers
+.rationalnum -- Addition for rational numbers
-.rationalnum -- Minus for rational numbers
/.rationalnum -- Division for rational numbers
Math.rationalnum -- Math group generic function for rational numbers
[.mathgraph -- Subscripting of mathematical graphs
[.queue -- Subscripting of queues
[.rationalnum -- Subscripting of rational numbers
[.stack -- Subscripting of stacks
[.verify -- Subscripting of test suites
[<-.mathgraph -- Replacement in mathematical graphs
[<-.queue -- Replacement in queues
[<-.rationalnum -- Replacement in rational numbers
[<-.stack -- Replacement in stacks
abs.rationalnum -- Absolute value of rational numbers
adjamat -- Adjacency matrix of a mathematical graph
adjamat.mathgraph
alldirected -- Convert mathematical graph to be a directed graph
alldirected.default
alldirected.mathgraph
as.numeric.rationalnum -- Coerce rational numbers to numeric
as.rationalnum -- Coerce to rational numbers
as.rationalnum.default
as.rationalnum.rationalnum
bind.array -- Glue two arrays together (like abind on StatLib, but different)
build.mathgraph
c.mathgraph -- Combine mathematical graphs
c.rationalnum -- Combine rational numbers
commontail -- Utility to decide inheritance
continue.fraction -- Compute continued fractions
delay.eval -- Fool with lazy evaluation
diffmask -- Look at differences of two objects with same name
diffsccs -- See if source control is up-to-date
digamma -- Compute digamma function of numeric or complex numbers
exp.integral -- Compute exponential integral of numeric or complex numbers
expand -- Generic function used in memory conservation scheme
expand.default
filetest -- Test aspects of Unix files
find.I.of
find.assign -- Find assignments within an S expression
from.base10
genopt -- Genetic optimizer
genopt.control -- Control parameters for genopt
getpath -- Find a path in a mathematical graph
getpath.adjamat
getpath.default
getpath.incidmat
getpath.mathgraph
global.vars -- Find global variables within a function
great.common.div -- Greatest common divisor
ignore.error -- Ignore an S error so computation can continue
incidmat -- Incidence matrix for a mathematical graph
incidmat.mathgraph
interlude -- Time profiling of S functions
interpolator.lagrange -- Create function that performs Lagrange interpolation
is.na.rationalnum -- Missing values in rational numbers
is.nan.rationalnum -- Not-a-numbers in rational numbers
justify -- Justify text in a character vector (left, right, center)
length.mathgraph -- Length of a mathematical graph
length.rationalnum -- Length of rational number vector
length<-.rationalnum -- Change length of rational number vector
line.integral -- Contour integral in complex plane (also real-valued)
loan -- Create monthly loan object
mathgraph -- Create mathematical graph
names.mathgraph -- Names of mathematical graph (edge names)
names.rationalnum -- Names of rational numbers
names<-.mathgraph -- Change names of mathematical graph
names<-.rationalnum -- Change names of rational numbers
numberbase -- Change base (radix) of numbers
numberbase.default
numberbase.numberbase
p.unpaste
perl -- Interface to Perl language
plot.mathgraph -- Plot a mathematical graph (very, very crude)
poet.data.restore -- Vectorization of data.restore
poet.dyn.load -- Dynamically load code for these functions
poet.verif -- Test suite for these functions
polygamma -- polygamma functions (complex numbers are not allowed)
portopt.control -- Control parameters for functions made by portoptgen
portopt1 -- Optimization of simple C or Fortran functions
portoptgen -- Optimization of general C or Fortran functions
portoptgen.ctemplate
portoptgen.stemplate
print.mathgraph -- Print a mathematical graph
print.numberbase -- Print numbers in some base
print.queue -- Print a queue
print.rationalnum -- Print rational numbers
print.stack -- Print a stack
print.verify -- Print a test suite
quad.form -- Compute quadratic forms
queue -- Create a queue
rationalnum -- Create rational numbers
reduce -- Generic function used in memory conservation scheme
reduce.default
reduce.rationalnum -- Put rational numbers into lowest terms
sccs -- Source code control for S objects
soptions -- Safe version of options
sort.mathgraph -- Sort a mathematical graph
stable.apply -- Substitute for apply that keeps dimensions the same in result
stack -- Create a stack
substifile -- Substitute patterns in a file
summary.interlude -- Time profiling of S functions
symbol.address -- The address of a loaded symbol
symsqrt -- Symmetric square root of a matrix
to.base10
transcribe -- Substitution within character strings
unabbrev.value -- Unabbreviate a character string passed in as an argument
uninterlude -- Time profiling of S functions
unique.mathgraph -- Unique edges in a mathematical graph
unique.rationalnum -- Unique rational numbers
update.loan -- Make payments on monthly loan
valid.s.name -- Test if a string is a "valid" S name
verify -- Run test suite
verify.default
verify.verify
whence -- Find the location where an object is found

Go to Burns Statistics Home.

Last Modified: 2008 March 01
Direct access to this location is: http://www.burns-stat.com/pages/spoetry.html