method可以为"spearman","pearson" and "kendall",分别对应三种相关系数的计算和检验。
1 perrson相关系数
>n <- 10
>x <- rnorm(n)
>y <- rnorm(n)
>cor(x,y)
[1] -0.4132864
>cor.test(x,y)
Pearson's product-moment correlation
data: x and y
t = -1.2837, df = 8, p-value = 0.2352
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
-0.8275666 0.2924366
sample estimates:
cor
-0.4132864
上面给出了相关系数的可信度区间和P-value
2 spearman相关系数和
kendall相关系数
同上,只要把method改成spearman和kendall
R语言 cov(a)函数返回的结果Population、Income、Illiteracy、LifeExp、Murder 、HSGrad分别是数据集“a"里的变量名称啊,要知道是什么意思,你需要去查看数据说明。