I have a data.frame with numeric values. How can I replace the each row maximum with 0
So for example in a row:
10, 1, 3, 4
the output would be
0, 1, 3, 4
I tried:
df1 <- data.frame(df)[apply(df,1,which.max=0)]
but I have something wrong.
I would be grateful for your help.
How about
or
EDIT to do rows
EDIT:2 to ensure data.frame