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

Peter Dalgaard BSA (p.dalgaard@biostat.ku.dk)
03 Jun 1998 12:35:24 +0200


To: Friedrich Leisch <Friedrich.Leisch@ci.tuwien.ac.at>
Subject: Re: R-beta: Re: "as.numeric" `mode' and `cast' should be kept separate.
From: Peter Dalgaard BSA <p.dalgaard@biostat.ku.dk>
Date: 03 Jun 1998 12:35:24 +0200
In-Reply-To: Friedrich Leisch's message of Wed, 3 Jun 1998 09:00:16 +0200 (CEST)

Friedrich Leisch <Friedrich.Leisch@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:

 read.table(file.dat)
 plot(x,y,type=l) 

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@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@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._