R/S compatibility in passing a formula

Peter Dalgaard BSA p.dalgaard@biostat.ku.dk
11 Apr 1999 02:16:31 +0200


Douglas Bates <bates@stat.wisc.edu> writes:

> In S3 if you are passing an evaluated formula to another function that
> will store it and use it in printing (such as a model-fitting function), you
> usually want to unclass the formula.  Otherwise, the formula that gets
> stored looks very ugly when printed.  A trick to do the unclassing is to pass
>  form = c( myFormula )
> In R this has the effect of making form a list rather than a call.  It
> seems that passing
>  form = as.vector( myFormula )
> will work in both dialects.  Anyone else have experience with this?

Apparently

(a) R does not print the class on a formula (because print.formula
unclasses it)
(b) as.vector does not unclass in R but does in S3. Try
class(as.vector(form)) 

So the result of as.vector *looks* alike, but isn't. Smells like
trouble... 

Whatever is wrong with using unclass() for unclassing anyway??

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._