R语言20-变量相关性

cor.test查看变量间的相关性

  • 相关性
cor.test(pf$age,pf$friend_count,method='pearson')

with(pf, cor.test(age,friend_count,method = 'pearson'))
  • 求解子集的相关性
with(subset(pf,age <= 70), cor.test(age,friend_count,method = 'pearson'))

还有其它的分析方法可供选择

相关分析法: Pearson’s r, Spearman’s ρ 及 Kendall’s τ
https://www.statisticssolutions.com/correlation-pearson-kendall-spearman/

发布了28 篇原创文章 · 获赞 0 · 访问量 415

猜你喜欢

转载自blog.csdn.net/xiuxiuxiu666/article/details/104244597