I want to create a column that contains the name of the column(s) with the minimum values. So far, I have only come across code that gives you a single name. In the case of ties, you can choose a tie break method. However, what I want to do is to list all column names in the case of a tie.
Minimum code:
df <- data.frame(ColA = c(0, 4, 7, 7, 3),
ColB = c(0, 2, 5, 3, 2),
ColC = c(5, 10, 1, 3, 1),
ColD = c(7, 3, 1, 3, 0))
To get a single column name I can do:
df$all.min.groups <- names(df)[apply(df, MARGIN = 1, FUN = which.min)]
Can you help me get all the column names that have the minimum value by row?