error in data.frame

Does your code feature a step where v would be created?

alternatively, if you could provide some example input data , and some cleaned up minimal code that takes you from a clear start point to the point of error in your code, then it would be possible for us to analyse it with you.