compute correlation in r 2 variables code example Example: calculate correlation in r cor(x, method = "pearson", use = "complete.obs")