Resolved: Tidyverse min{x, 1-x} by column 0 By Isaac Tonny on 17/06/2022 Issue Share Facebook Twitter LinkedIn Question: My data is the following: tibble(var1.q = 0.01, var2.q = .99, var3.q = .45) -> foo I would like to calculate 2 * min{x, 1-x} for each column. In base R, I could do 2*apply(bind_rows(foo, 1-foo), 2, FUN=min) but I struggle to find the tidyverse equivalent of this. Expected result: 0.02 0.02 0.90 Answer: A possible solution, using pmin (parallel min) to calculate the min rowwise: library(dplyr) foo %>% mutate(across(everything(), ~ 2 * pmin(.x, 1-.x) )) #> # A tibble: 1 × 3 #> var1.q var2.q var3.q #> #> 1 0.02 0.0200 0.9 If you have better answer, please add a comment about this, thank you! r tidyverse