I have a dataset that looks like this:
V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
2 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1
3 1 1 1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1
4 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1
5 1 -1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 -1
6 1 -1 -1 1 1 -1 -1 -1 -1 1 1 -1 -1 1 1
7 1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 1 1
8 1 -1 -1 -1 -1 1 1 -1 -1 1 1 1 1 -1 -1
9 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1
10 -1 1 -1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 1
11 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1
12 -1 1 -1 -1 1 -1 1 -1 1 -1 1 1 -1 1 -1
13 -1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 1
14 -1 -1 1 1 -1 -1 1 -1 1 1 -1 -1 1 1 -1
15 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1
16 -1 -1 1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 1
and I want to combine the first three colums into a single base on some principle:
1 1 1 → 1
1 -1 -1 → 2
-1 1 -1 → 3
-1 -1 1 → 4
This is my first time to use R language. I have no idea about how to do it. Does anyone have some simple pieces of code to do this? Thanks in advance!