Regarding 1), in my code the variable is the same throughout the code. Effectively, it was a mistake that I did when I wrote the message in research gate.
Considering 2), I have already tried to convert to a factor the variable "factor 1" at the beginning of the code as follows: