This error message means you're trying to do an operation that requires a vector of the same length, or two tables that require the same number of rows, and these are not being provided to a function that requires it.
Given the code provided it's hard to tell at which point this error occurred. Ideally, you'd pose this question with a reprex and example-dummy data (FAQ: What's a reproducible example (reprex
) and how do I do one? ).