Re: [R] Is this a bug with a simple arithmetic operation with a vector object?

About this list Date view Thread view Subject view Author view

From: A. J. Rossini (rossini@u.washington.edu)
Date: Sun 01 Apr 2001 - 04:45:03 EST


Message-ID: <Pine.A41.4.33.0103311043310.29670-100000@homer09.u.washington.edu>


On Sun, 1 Apr 2001, hzi wrote:

> Hello-
>
> While I was reading a tutorial book for R (actually, for S-Plus:Brian S. Everitt. A Handbook of Statistical Analysis using S-PLUS. Chapman & Hall, London, 1994) I tried to execute this simple exercise:
>
> > x <- -c(1,2,3,4,5,6)
> > X <- -c(10,11,12,100,-5,-6)
> >x+X
> [1] -11, -13, -15, -104, 0, 0
>
> As you can see, the added vectors resulted in negative numbers ! (the answer should have been: [1] 11, 13, 15, 104, 0, 0)
> Mind you, this is R 1.2.1 for Windows, under WIndows ME, 64 Mb RAM, pIII 800 MHz. The same thing happens, however, with the recently distributed "R 1.2.2 patched".
> Clues, anyone?

Of course. "<-" is assignment, but "-c(1,2,3,4,5,6)" = "c(-1,-2,-3...".
Well, you get the drift. You've added a negative sign where you don't
want one.

best,
-tony

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view

This archive was generated by hypermail 2b30 : Fri 22 Jun 2001 - 18:58:38 EST