Dea12
Dea12

Reputation: 55

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

I hope you won't downvote me for this question, i know there are a few ones asked here about the same topic but i can't understand why this happens.

I get this error message: Warning:

1. In test* rep(mean(c(sec)), n) + (1 - test) * c(sec)

longer object length is not a multiple of shorter object length

Now, the formula is:

  Sec<-  test* rep(mean(c(sec)), n) + (1 - test) * c(sec)

the sec takes values from a txt file.

Could you help me understand it? Where should i look?

Thanks in advance

Upvotes: 0

Views: 5662

Answers (1)

djhurio
djhurio

Reputation: 5536

The syntax can be rewritten as

Sec <- test * rep(mean(sec), n) + (1 - test) * sec

I believe the problem is that the length of objects is not the same.

Check:

length(test)
n
length(sec)

If n is one, then you do not need repetition in this case. Try this code:

Sec <- test * mean(sec) + (1 - test) * sec

What are the classes of test and sec?

class(test)
class(sec)

Upvotes: 1

Related Questions