Q:

Pulling column name with associated value and adding just the column name to a new vector

Let's say I have a dataframe like the one below and want to take the highest value in each row and put its associated column name into a new vector (not the value itself), how could I go about this? 
df <- data.frame(matrix(rnorm(50, 20), 5))

  X1       X2       X3       X4       X5       X6       X7       X8       X9      X10
1 18.49755 18.98823 18.53194 18.86478 20.74333 18.04460 21.08717 21.75072 18.05813 19.08402
2 20.44626 20.07205 19.36755 17.14943 18.58396 20.76463 20.23776 18.90171 18.99182 20.51338
3 20.27142 18.74448 21.42953 20.13568 20.40065 22.26788 19.30967 20.51772 19.20067 19.75371
4 20.61600 21.27852 18.54137 20.84269 20.27767 20.70583 21.33051 20.03136 20.60405 21.24672
5 19.64165 21.20197 20.06732 19.59529 20.48761 19.83571 19.80155 21.02669 20.77574 21.21862

I have tried 
results <- apply(df, 1, max)

which gives me the highest value but I am more interested in the column name associated with the highest value being added to the result vector, not the value itself.  
So, instead of a vector of the 5 highest values by row, I would have a vector of the column names that "won" such as
result <- c("X1", "X3", "X2", "X1", "X9")

Thank you. 

A:

Use which.max:
names(df)[apply(df, 1,which.max)]

