col_max: Get the column name of the max/min number each row

Description Usage Arguments Value References Examples

View source: R/col_max.R

Description

For a data.frame with numeric values, add a new column specifying the column name of the max/min value each row.

Usage

1
2
3
col_max(.data, .name = "max_col")

col_min(.data, .name = "min_col")

Arguments

.data

A data.frame with numeric column(s)

.name

The column name of the new added column

Value

A data.table

References

https://stackoverflow.com/questions/17735859/for-each-row-return-the-column-name-of-the-largest-value

Examples

1
2
3
4
5
6
7
8
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)

tidyfst documentation built on Sept. 8, 2021, 9:08 a.m.