I have dataframe dih_y2. These two lines give me a warning:
> memb = dih_y2$MemberID[1:10]
> dih_col = which(dih_y2$MemberID == memb)
Warning message:
In dih_y2$MemberID == memb :
longer object length is not a multiple of shorter object length
Why?
You don’t give a reproducible example but your warning message tells you exactly what the problem is.
membonly has a length of 10. I’m guessing the length ofdih_y2$MemberIDisn’t a multiple of 10. When using==, R spits out a warning if it isn’t a multiple to let you know that it’s probably not doing what you’re expecting it to do.==does element-wise checking for equality. I suspect what you want to do is find which of the elements ofdih_y2$MemberIDare also in the vectormemb. To do this you would want to use the%in%operator.