What is the opposite function of max.col
(R language).
I couldn't find min.col
or relevant info in the manual:
https://stat.ethz.ch/R-manual/R-devel/library/base/html/maxCol.html
I'm trying to generate an opposite function of this:
cols = which(names(df) %in% c( "avp", "USD.KRW","cd"));
df$max_col = names(df)[cols][max.col(df[cols])]
You can use
min.col <- function(m, ...) max.col(-m, ...)
Used in formal optimization (where many tools prefer to find a minimum of a function), the opposite of a maximal number is the minimal negative number.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With