Hi all,
I have a dataset like this:
id type var1 var2 var3 var4
1 1 0 1 2 3
1 2 1 0 1 3
2 1 0 0 1 2
2 2 1 2 3 4
[My actual dataset has var1, var2, var3, ... var599, var600]
My final goal is to calculate the distance between two vectors identified by the "type" variable for each id. For example: for id=1 I want to calculate the distance between (0 1 2 3) and (1 0 1 3)
The distance is the angle between the two vectors, or, second best option, the Euclidean distance.
I thought that one way could be to create vectors from the "var*" variables for each combination "id" "type" . But I do not know how to do it.
And maybe that is not the best way to approach the problem.
Thank you in advance for any help you will give me
I have a dataset like this:
id type var1 var2 var3 var4
1 1 0 1 2 3
1 2 1 0 1 3
2 1 0 0 1 2
2 2 1 2 3 4
[My actual dataset has var1, var2, var3, ... var599, var600]
My final goal is to calculate the distance between two vectors identified by the "type" variable for each id. For example: for id=1 I want to calculate the distance between (0 1 2 3) and (1 0 1 3)
The distance is the angle between the two vectors, or, second best option, the Euclidean distance.
I thought that one way could be to create vectors from the "var*" variables for each combination "id" "type" . But I do not know how to do it.
And maybe that is not the best way to approach the problem.
Thank you in advance for any help you will give me
Comment