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

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Fri Feb 14 09:29:03 CET 2003


On Fri, 14 Feb 2003 j+rhelp at howard.fm wrote:

[...]

> Thanks for the suggestion. After my last post I tried switching from
> SPLUS to R and discovered the useful xlevels attribute, which when output

Eh?  S-PLUS has an "xlevels" attribute, but R has an "xlevels" component
(speaks the author of both).

> with expression(), combined with the coefficients attribute, gives me the
> information I need. dump() also provides those things, although it has a
> lot of other stuff not needed to build the prediction function.
> 
> I'll start coding something using this, but it won't be ideal. The two
> problems are:
>  - The variable name / level name are still concatenated with
>    no delimiter in the coefficients, so it's possible there will
>    be ambiguous names
>  - It feels rather clunky to be relying on these attributes when
>    I feel like I should be adding methods directly to the class
>    somehow...

You add methods to functions, not classes, in R.  You could indeed add
generic accessor functions with lm methods, but their absence (and the
lack of documentation of the internal structure) should alert you to the
idea that this is internal structure and not part of a public API.

> In SPLUS I came across a useful attribute 'assign', which has a mapping
> of term names to variables - the same attribute in R doesn't appear to
> provide this information. Is this available somewhere?

Both have an assign *component*, not attribute.  R has a mapping from
model.matrix columns to terms in its assign component: that's not an
accurate description of S-PLUS's component ....

> What approaches are others using to apply their models to data sets where
> S is not available? Has anyone written any convertors of models to other
> languages? Is it possible to compile an expression or model into a DLL or
> COM object and access it that way? I'm aware of the SOAP interface, but
> that doesn't really suit our needs in this case.

As I have just posted, in general this is impossible.  We just send new 
data to R and get back the model matrix (using CORBA at present).

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list