Get Started →
Type & Coercion Errors

Vector length not a multiple

Matches: longer object length is not a multiple of shorter object length

WHAT THIS ERROR MEANS

You're operating on two vectors where the longer one's length is not a clean multiple of the shorter one. R will still recycle, but the result may not be what you intended.

HOW TO FIX IT

1. Check vector lengths with length().

2. Make sure vectors are the same length for element-wise operations.

3. Explicitly recycle with rep() if intentional.

CODE EXAMPLES

BAD — THIS CAUSES THE ERROR
c(1, 2, 3) + c(10, 20)  # 3 is not a multiple of 2
GOOD — CORRECT APPROACH
c(1, 2, 3) + c(10, 20, 30)  # same length

Still stuck?

Paste your code in RChat and the AI will fix this error in context.

Try RChat Free →

RELATED TYPE & COERCION ERRORS