[Rd] R-intro: Simple manipulations/Vectors and assignment (PR#2365)

nvj@fys.ku.dk nvj@fys.ku.dk
Thu Dec 12 00:17:02 2002


Full_Name: Niels Vestergaard Jensen
Version: 1.6.1
OS: Linux (Mandrake 9.0)
Submission from: (NULL) (62.79.36.179)


The R-intro (1.6.1 (2002-11-01)) says in Simple manipulations/Vectors and
assignment:

"So with the above assignments the command 

> v <- 2*x + y + 1

generates a new vector v of length 11 constructed by adding together, element by
element, 2*x repeated 2.2 times, y repeated just once, and 1 repeated 11
times."

That's apparently not true:

> x <- c(10.4, 5.6, 3.1, 6.4, 21.7)
> y <- c(x, 0, x)
> x
[1] 10.4  5.6  3.1  6.4 21.7
> y
 [1] 10.4  5.6  3.1  6.4 21.7  0.0 10.4  5.6  3.1  6.4 21.7
> v <- 2*x + y + 1
Warning message:
longer object length
        is not a multiple of shorter object length in: 2 * x + y

Which was run first thing after starting R in a dir without .Rdata. I suspect R
has been updated, but the R-intro has not kept up.

See also: http://www.zoo.ufl.edu/bolker/emd/R/R-traps.html