I am trying to add two vectors in R but I am getting the warning" longer object length is not a multiple of shorter object length" what does this warning signify??

I am adding

c(1, 2, 3, 4) + c(0, 10, 100)

I am trying to add two vectors in R but I am getting the warning" longer object length is not a multiple of shorter object length" what does this warning signify??

I am adding

c(1, 2, 3, 4) + c(0, 10, 100)

Your function results in `1 12 300 4`

. Now that may be what you meant to do, but R is nice enough to warn you that it may have not been intended. One vector has 4 items, the other only has 3. They don’t match. And furthermore, you cannot copy the smaller one again to match the length of the bigger one (not a multiple). Some people realize that this was a mistake and add another element to the second to have equal amounts.

The evaluator added:

`1+0=1, 2+10=12, 3+100=300, 4+? (whoa there aren't anymore values in the 2nd vector)`

It noticed that you didn’t have another value to match with 4. So it started again at the beginning of the 2nd vector, `0`

, and continued the addition:

`4+0=4`

That is called recycling. It recycles the smaller vector to finish the operation. The warning just says, “Beware, R recycled the second vector for you and didn’t use all of them. Check to make sure this is what you wanted.”