【问题标题】:different coefficient corrplot() and cor.test()不同的系数 corrplot() 和 cor.test()
【发布时间】:2020-06-19 23:50:47
【问题描述】:

我计算了航班数据集所有可能组合的相关系数。我首先使用 corrplot 做到了这一点。结果是组合小时和 sched_dep_time 的系数为 1。但是使用 cor.test() 它告诉我值接近 1 但为 0.9906496。

这是我的代码:

# the corrplot
a <- flights %>% select(year, month, day, dep_time, sched_dep_time, dep_delay, arr_time, sched_arr_time, arr_delay, flight, air_time, distance, hour, minute)
corrplot(cor(na.omit(a)), method = "number")
# using cor.test
cor.test(flights$hour, flights$sched_dep_time, method = "pearson")

这种差异的解释是什么?

【问题讨论】:

    标签: r correlation r-corrplot


    【解决方案1】:

    这似乎是一个四舍五入的问题。当你这样做时

    library("corrplot")
    corrplot(cor(na.omit(a)), method = "number", number.digits=4, number.cex=.5)
    

    系数匹配得更好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-08
      相关资源
      最近更新 更多