This question already has an answer here:
- For each row return the column name of the largest value 7 answers
Let's say that my data frame contains
> DF
V1 V2 V3
1 0.3 0.4 0.7
2 0.4 0.2 0.1
3 0.2 0.8 0.3
4 0.5 0.8 0.9
5 0.2 0.7 0.8
6 0.8 0.3 0.6
7 0.1 0.5 0.4
the rows would be the different types of automobiles, and the columns would be the probabilities for a given category of V1, V2, V3.
I want to generate a vector that assigns to each automobile the category of which it has the highest probability in. For example, I'd want automobile 1 to be associated with V3, automobile 2 to be associated with V1, automobile 3 to be associated with V2.
Any aids or hints on how I should tackle this?