how to know if two variables are correlated in r code example Example: calculate correlation in r cor(x, method = "pearson", use = "complete.obs")