RE: [S] creating dummies from dyads

Gunter, Bert (
Mon, 04 May 1998 08:22:10 -0400


1) I doubt that you need to create dummy variables for whatever it is that
you intend to do. S-Plus usually does appropriate coding itself internally.
for whatever modeling or graphing procedure you need. This sounds like a
leftover from SAS or SPSS or something.

2) Nevertheless, it is easy to do what you want using substring(). For
example, if dyad.code is the variable coding your dyads,
substring(as.character(10000+dyad.code),first=2,last=3) extracts the first
2 digits of your code (as characters -- use as.numeric() to get the data
back to numeric, which probably is not necessary anyway). It is necessary to
add 10000 first to avoid losing the initial 0 in 0123, etc. I suspect
others willl suggest slicker ways to do this.

3. However: Questions like this can easily be answered using the Help
facility (Contents .. Character operations ....would have led you right to
substring() ). I realize that sometimes you don't know how to start and so
don't know where to look, but I urge all to first have a go at Help (and
S-Plus manuals and Ripley-Venables) before posting to the group. And, yes
... mea culpa!


Bert Gunter
This message was distributed by To unsubscribe
send e-mail to with the BODY of the
message: unsubscribe s-news