Tidyverse calculate R squared when different order code example Example: how to get the r2 value in r rsq <- function (x, y) cor(x, y) ^ 2