From hanson at depauw.edu  Thu Sep  4 20:47:34 2014
From: hanson at depauw.edu (Bryan Hanson)
Date: Thu, 4 Sep 2014 14:47:34 -0400
Subject: [Rd] negative numerics in []
In-Reply-To: <2D13E3F7-A7AE-4614-959B-B48C74E60D62@oracle.com>
References: <2D13E3F7-A7AE-4614-959B-B48C74E60D62@oracle.com>
Message-ID: <D8E0BDA6-79F5-47C6-968C-4616D3037EAC@depauw.edu>

Just for the sake of completeness, I raised a closely related issue back in 2010 which my students discovered.

https://stat.ethz.ch/pipermail/r-help/2010-March/231788.html

Bryan

On Sep 4, 2014, at 11:17 AM, Michael Haupt <michael.haupt at oracle.com> wrote:

> Hello,
> 
> I'm a bit puzzled by what looks (to me) like a discrepancy between documentation and implementation.
> 
> The documentation for [] says this about the indices: "Numeric values are coerced to integer as by as.integer (and hence truncated towards zero)."
> 
>> as.integer(-3.1)
> [1] -3
> 
> Good. But:
> 
>> x <- c(1,2,3)
>> x[-3.1]
> [1] 1 2 3
> 
> Given the documentation, I'd have expected a result of "[1] 1 2", because -3.1 should be coerced to -3 (by virtue of as.integer).
> 
> What bit do I not get? (I'm using R 3.1.1, if that matters.)
> 
> Best,
> 
> Michael
> 
> -- 
> Dr. Michael Haupt
> Principal Member of Technical Staff
> Phone: +49 331 200 7277, Fax: +49 331 200 7561
> Oracle Labs
> Oracle Deutschland B.V. & Co. KG, Schiffbauergasse 14, 14467 Potsdam, Germany
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] negative numerics in []
Bryan Hanson