I have two files: the first one contains lines where the first column is an ID, and the remaining columns are votes, e.g.
3242 -1 1 -1 1 1 1
In a first step I want to calculate the majority for the IDs. For the example above, the vote is 1 (since there are more positive votes then negative ones). I would like to store the results in an output file with lines such as
I also have a file that contains the 'weights' of the respective votes, e.g.
3242 0.9 0.1 0.9 0.2 0.1 0.2
In a second step, I also want to calculate the weighted votes for the different lines. In this case this would be
(0.9 * -1) + (0.1 * 1) + (0.9 * -1) + (0.2 * 1) + (0.1 * 1) + (0.2 * 1) = -1.2
The result is negative, so the vote should be -1. Again, I would like to store this in an output file, where each line contains the ID and the resulting vote.
Would this be possible with awk, perl,...?