powered by
For a data.frame with numeric values, add a new column specifying the column name of the first max/min value each row.
col_max(.data, .name = "max_col")col_min(.data, .name = "min_col")
col_min(.data, .name = "min_col")
A data.table
A data.frame with numeric column(s)
The column name of the new added column
https://stackoverflow.com/questions/17735859/for-each-row-return-the-column-name-of-the-largest-value
set.seed(199057) DT <- data.table(matrix(sample(10, 100, TRUE), ncol=10)) DT col_max(DT) col_max(DT,.name = "max_col_name") col_min(DT) col_max(iris)
Run the code above in your browser using DataLab