Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is the opposite of max.col()

I want a function that does the opposite of max.col() (which would be min.col)

There is an answer for this, but I don´t really understand it. Could anybody give a different solution?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Negate the columns. Using BOD which comes with R:

max.col(BOD)
## [1] 2 2 2 2 2 2

max.col(-BOD)
## [1] 1 1 1 1 1 1

If the data frame is not numeric use xtfrm first

DF <- data.frame(X = c("a", "b", "a"), Y = c("b", "a", "b"))
max.col(-t(apply(DF, 1, xtfrm)))
## [1] 1 2 1
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading