[R] Translating lm.object to SQL, C, etc function

j+rhelp@howard.fm j+rhelp at howard.fm
Fri Feb 14 06:38:03 CET 2003

This is my first post to this list so I suppose a quick intro is in
order. I've been using SPLUS 2000 and R1.6.2 for just a couple of days,
and love S already. I'm reading MASS and also John Fox's book - both have
been very useful. My background in stat software was mainly SPSS (which
I've never much liked - thanks heavens I've found S!), and Perl is my
tool of choice for general-purpose programming (I chaired the
perl6-language-data working group, responsible for improving the data
analysis capabilities in Perl).

I have just completed my first S project, and I now have 8 lm.objects.
The models are all reasonably complex with multiple numeric and factor
variables and some 2-way and 3-way interactions. I now need to use these
models in other environments, such as C code, SQL functions (using CASE)
and in Perl - I can not work out how to do this.

The difficulty I am having is that the output of coef() is not really
parsable, since there is no marker in the name of an coefficient of
separate out the components. For instance, in SPSS the name of a
coefficient might be:


...which is easy to write a little script to pull that apart and turn it
into a line of SQL, C, or whatever. In S however the name looks like:


...which provides no way to pull the bits apart.

So my question is, how do I export an lm.object in some form that I can
then apply to prediction in C, SQL, or some other language? All I'm
looking for is some well-structured textual or data frame output that I
can then manipulate with appropriate tools, whether it be S itself, or
something like Perl.

Thanks in advance for any suggestions (and apologies in advance if this
is well documented somewhere!),


More information about the R-help mailing list