First I have found the min and max value of a tibble
:
library(dplyr)
name <- c("a","b")
x <- c(1,2)
y <- c(3,4)
df <- as_tibble(data.frame(name,x,y))
min_max <- df %>%
select(-name) %>%
summarize(min(.), max(.))
In this case min=1 and max=4
> min_max
# A tibble: 1 x 2
`min(.)` `max(.)`
<dbl> <dbl>
1 1 4
How can I find the row and column names of min and max? The answer in this case should be ("a",x) and ("b",y). I tried which
with no result.