function for r^2 code example Example: how to get the r2 value in r rsq <- function (x, y) cor(x, y) ^ 2