cor.test错误,结果显示以下...没有足够的有限观察

时间:2014-08-20 17:20:04

标签: r correlation

我正在尝试进行相关性测试。相反,我收到以下错误。

cor.test.default中的错误(指标,Revpolu):   没有足够的有限观察这是什么意思?

脚本停在 table_corr< - setDT(table)[,list(Revpolu,Indicator),by = list(Club,Date)]

table_corr 变量存储了4个变量的1161个观测值。

library(data.table)

dat <- read.csv("corrtest.csv", header = TRUE)

dat$Date <- as.Date(paste0(format(strptime(as.character(dat$Date), 
                                       "%m/%d/%y"), 
                              "%Y/%m"),"/1"))

table <- (setDT(dat)[, list(Revenue = sum(Revenues),
                               Hours = sum(Hours),
                               Indicator = mean(Indicator)), 
                        by = list(Club, Date)])

table$Hours[table$Hours == 0 ] <-NA

table <- table[complete.cases(table), ]

table[, Revpolu := Revenue / Hours]

table_corr <- setDT(table)[, list(Revpolu, Indicator), 
                              by = list(Club, Date)]

testing <- table_corr[, list(Correlation = cor.test(Indicator, Revpolu)[["estimate"]]), 
                        by = Club]

testing <- testing[complete.cases(testing), ] 

correl <- testing[, round(Correlation, digits = 2)]

done <- round(mean(correl), digits = 2)

0 个答案:

没有答案