I have a vector, say
1
0
1
1
1
0
denoting gender. I want to matricise this vector into an square matrix and for every pair perform a function. So say I want to sum.
2 1 2 2 2 1
1 0 1 1 1 0
2 1 2 2 2 1
2 1 2 2 2 1
2 1 2 2 2 1
1 0 1 1 1 0
Or if the rule is ‘similar is a 1’
1 0 1 1 1 0
0 1 0 0 0 1
1 0 1 1 1 0
1 0 1 1 1 0
1 0 1 1 1 0
0 1 0 0 0 1
How can I create such a square matrix from a vector/column c(1,0,1,1,1,0)
?
I have been manipulating numerous vectors but I keep on getting errors.