Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
不同系数corrplot()和cor.test()_R_Correlation_R Corrplot - Fatal编程技术网

不同系数corrplot()和cor.test()

不同系数corrplot()和cor.test(),r,correlation,r-corrplot,R,Correlation,R Corrplot,我计算了飞行数据集所有可能组合的相关系数。我先用corrplot做了这个。计算结果表明,小时和计划执行时间的组合系数为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, fligh

我计算了飞行数据集所有可能组合的相关系数。我先用corrplot做了这个。计算结果表明,小时和计划执行时间的组合系数为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")
#正确的绘图
a%选择(年、月、日、起飞时间、预定起飞时间、起飞延迟、到达时间、预定起飞时间、起飞延迟、航班、飞行时间、距离、小时、分钟)
corrplot(cor(na.省略(a)),method=“number”)
#使用cor.test
cor.test(航班$hour,航班$sched_dep_time,method=“pearson”)

这种差异的原因是什么?

这似乎是一个取整问题。当你这样做的时候

library("corrplot")
corrplot(cor(na.omit(a)), method = "number", number.digits=4, number.cex=.5)
系数匹配得更好