[R] object length
Jim Lemon
bitwrit at ozemail.com.au
Wed Dec 21 04:43:19 CET 2005
linda.s wrote:
> Why I got warning from the following code?
>
>>assign("x", c(10, 5, 4, 2, 2))
>>y <- c(x, 0, x)
>>y
>
> [1] 10 5 4 2 2 0 10 5 4 2 2
>
>>v <- 2*x + y + 1
>
> Warning message:
> longer object length
> is not a multiple of shorter object length in: 2 * x + y
>
>>v
>
> [1] 31 16 13 7 7 21 21 14 9 7 23
>
Because the y vector contains 11 elements and the x vector contains 5.
The message is just to warn the user that the elements of the shorter
vector will not be uniformly represented in the result.
Jim
More information about the R-help
mailing list