[Rd] asmode.integer() -- RFC

Bill Venables Bill.Venables@cmis.csiro.au
Thu, 07 Sep 2000 20:00:23 +1000


At 10:17 07/09/00 +0200, Martin Maechler wrote:
>Many of us known that sometimes, e.g. in calls to .C(..), you want to
>basically say
>	  
>	  x <- as.integer(x)
>
>but you can't do that because as.vector() 
>and it's descendants such as as.integer, as.double, as.character
>drop all attributes.
>
>Several months ago, someone proposed to use a new function
>As.integer() instead.  
>Since I just now again "stumbled" on it, I wondered if it might be worth to
>define 
>
>      asmode.integer   <- function(x) { mode(x) <- "integer"   ; x }
>      asmode.double    <- function(x) { mode(x) <- "double"    ; x }
>      asmode.character <- function(x) { mode(x) <- "character" ; x }

The idiom in "another place" is

storage.mode(x) <- "integer"
storage.mode(x) <- "double"  &c

my preference would again be for convergence of the two dialects.

(Of course when S4 takes over that other place, this sort of consideration
becomes much less relevant.)

Bill Venables.

>in order to encourage more shorter & more readable code...
>or would you hate to see yet more functions doing `almost the same' as
>others do?
>
>[RFC = Request for comments]
>
>Martin Maechler <maechler@stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
>Seminar fuer Statistik, ETH-Zentrum  LEO D10	Leonhardstr. 27
>ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
>phone: x-41-1-632-3408		fax: ...-1228			<><
>-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
.-.-
>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
>_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
._._
>
>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._