n = 100 # (sample size) data = data.frame(A = sample(1:20, replace = TRUE, size = n), B = sample(1:30, replace = TRUE, size = n))
library(Hmisc) rcorr(data$A, data$B, type="pearson") #> x y #> x 1.00 0.17 #> y 0.17 1.00 #> #> n= 100 #> #> #> P #> x y #> x 0.0878 #> y 0.0878
library(Hmisc) rcorr(data$A, data$B, type="spearman") #> x y #> x 1.00 0.18 #> y 0.18 1.00 #> #> n= 100 #> #> #> P #> x y #> x 0.08 #> y 0.08