[Rd] x[c()] <- value sets the mode to mode(value)

William Dunlap wdunlap at tibco.com
Wed Dec 9 02:54:28 CET 2009


> -----Original Message-----
> From: r-devel-bounces at r-project.org 
> [mailto:r-devel-bounces at r-project.org] On Behalf Of Henrik Bengtsson
> Sent: Tuesday, December 08, 2009 5:45 PM
> To: R-devel
> Subject: [Rd] x[c()] <- value sets the mode to mode(value)
> 
> Only for the record,
> 
> an unnecessary overhead when nothing is assigned:
> 
> > x <- integer(10)
> > str(x)
>  int [1:10] 0 0 0 0 0 0 0 0 0 0
> > x[c()] <- 1.0;
> > str(x)
>  num [1:10] 0 0 0 0 0 0 0 0 0 0
> 
> 'x' could equally well have renamed untouched.

I disagree.  I think the language is more predictable,
hence easier to use, if the class of the output of a
function depends only on the classes of the inputs,
not on the classes and lengths of the inputs.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

> 
> /Henrik
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 



More information about the R-devel mailing list