Hello folks, I ran into a small problem when I was trying to count the frequency of change in a set of variables , below is a sample of how the data looks like:
in which ID stands for participant ID and there are five variables cat1 through cat5. Each variable has the same range of values from 1 to 5. However, I need to create a new variable counting the times of change from cat1 to cat5. For instance, for ID 110, the frequency of change from cat1 to cat5 is 1, for ID 155, the frequency of change from cat1 to cat 5 is 4. I hope I make myself clear. Is there any way for me to capture this information cuz I have a quite large data set. Thanks!
Code:
ID cat1 cat2 cat3 cat4 cat5 110 1 1 1 1 3 134 1 2 3 1 1 123 3 3 3 1 5 145 4 5 1 1 1 155 5 3 2 4 1 167 4 4 3 1 2 147 5 5 5 5 5 166 4 3 3 3 1 148 4 5 4 4 1
Comment