I am looking for a solution for min(or max) value for each row of columns. Like:
# my data.frame is df:
library(tibble)
df <- tribble(
~name, ~type_1, ~type_2, ~type_3,
"a",   1,   5, 2,
"b",   2,   2, 6,
"c",   3,   8, 2
)
# and output should be result_df:
result_df <- tribble(
~name, ~type_1, ~type_2, ~type_3, ~min_val, ~min_col,
"a",   1,          5,     2,          1, "type_1",
"b",   8,          2,     6,          2, "type_2",
"c",   3,          8,     0,          0 ,"type_3"
)
I tried rowwise and pmax function but it did not work. I can use gather and grouping but I want to know is there column/row-wise solution.
This approach will be also useful for mean, median functions.
Thanks for your help.