The first part is just:
GatherBy[data, Last]
For easy manipulation you might use this:
ruleData= #[[1, -1]] -> # & /@ GatherBy[data, Last];
Then get the part you want with e.g.:
4 /. ruleData
{{41, 49.32, 4}, {41, 48.21, 4}, {47, 48.87, 4}, . . .}
You'll have to explain in more detail what you mean by:
How do I test whether these two data sets are linearly independent?