Re: [S] Must have S-Plus 4 add ons?

Mark Bravington FSMG CEFAS (M.V.BRAVINGTON@cefas.co.uk)
Mon, 9 Mar 1998 17:28:03 +0000


[Marc Feldemann asks what extras he should get hold of for running Splus 4, besides V&R2]

Marc--

This is not about statistics, but about getting statistics done. When I started Splus several years ago, I soon ran into 3 problem areas:

(1) Organizing projects
(2) Editing functions that I wrote
(3) Debugging the selfsame functions

(1) Splus does not provide a very handy of organizing projects; if you want to keep separate pieces of work in separate directories, the manual suggests starting Splus with different S_PROJ command-line parameters. There is then no very easy way of switching stuff between projects, sharing code, seeing what's in other projects, figuring out where you left useful pieces of code, etc.

It is possible to kludge your way around some of this, using the "attach" and "detach" functions to add "libraries" to the search list (the directories where Splus looks for and stores objects). But to do all this smoothly, and to provide a fully hierarchical directory structure within S (like the DOS or UNIX directory structure), I have written a set of project management routines that don't require you to start Splus anew each time you change projects etc. These routines have been used by quite a lot of people by now; I have just released a version for Splus 4. The routines aren't on Statlib (yet); please email me if you would like a copy.

(2) To do something repeatedly in Splus, you need to either write a script, or create a function. If you want write a function, the manuals might on a good day point you in the direction of the function "fix", which invokes an editor on a new or existing bit of code. But "fix" is horrible. It doesn't allow you to return to S until you have finished editing the function; it only allows you to have one code window open at a time, so you can't cut-and-paste code between functions; and it mangles your source code, changing all the spacing and moving comments around. Sometimes, comments disappear altogther: a particularly endearing habit, especially if you have "temporarily" commented out a block of code.

I have written a replacement "fix" that fixes these problems. It works with standard readily-available programming editors (e.g. TextPad or PFE, which are readily available over the Internet. PFE is freeware). The relevant Splus code is distributed along with the project management utilities.

With version 4, the manuals seem to focus on writing scripts. However, functions have many advantages over scripts. In particular, functions parameters which can easily be changed, and functions have no nasty side-effects of creating unwanted variables, or accidentally overwriting precious existing ones. If you are doing absolutely routine analyses, then scripts are fine; but if you do any developing of new analyses, then I think functions are much better.

(3) New functions have bugs. Splus now has a debugger, though it must be said that the debugger is not a thing of beauty nor a joy forever, at least not if you have programmed in other languages this side of the Stone Age. At some point before the debugger came out, I wrote a better one, which offers source-code viewing, line-numbered debugging, graceful error recovery, etc. I have recently tarted this up for version 4, and will be releasing it soon.

There is a general issue about "ways of working" in Splus, which doesn't get addressed in the books, or even much in this newsgroup. Your question is very relevant for all new users. It is a lot better to get the basics sorted out to begin with, rather than try to organize things post-hoc. I presume that most long-time Splussers have painfully evolved their own ways of getting things done, but not much seems to be written on it, at least not from a non-partisan perspective. "Ways of working" seems like a useful area for further discussion on this newsgroup.

This is of course a heavily partisan posting, in that I favour my own way of working. But I'm not trying to plug my own code, so much as to point out which the bare-bones Splus handles badly, and to suggest ways round them. There are lots of alternatives to my stuff. Many people like to run S "through" EMACS; there is or used to be a whole newsgroup on that side of things, and a query to s-news will put you on the right track if that appeals to you. No doubt there are other approaches. I remember somebody putting together a compendium of editing solutions (BTW pre-dating my current version of "fix").

Hope this is of some use!

Mark Bravington
m.v.bravington@cefas.co.uk
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news