R-beta: Re: "as.numeric" `mode' and `cast' should be kept separate.

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Wed Jun 3 12:35:24 CEST 1998

Friedrich Leisch <Friedrich.Leisch at ci.tuwien.ac.at> writes:

> >> "%cast.as%" <- function(x, form) {
> >> storage.mode(x) <- deparse(substitute(form))
> >> x
> >> }
> RI> This certainly appeals to me straight away!  A very nice suggestion.
> I add a second PRO vote.

I think I have at least half a CON: Is it necessary to do the
deparse(substitute(form)) bit, just to get rid of the quotes? There
are many occasions where you *feel like* doing that in R/S, but
refrain from it, realising that you really want to be able to pass the
argument in a variable, sometimes.

Some examples are:


On the other hand, help and apropos already contain logic to allow
unquoted arguments.

Without that piece of logic one could just

> "%as%"<-.Alias(get("storage.mode<-"))

> pi %as% "integer"
[1] 3

This doesn't change pi, BTW:

> pi
[1] 3.141593

   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907

r-help 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-help-request at stat.math.ethz.ch

More information about the R-help mailing list