问题描述
> Error in cor.test.default(DT[,"name2"],DT[,4:ncol(DT)],method = c("pearson")) :
> 'x' and 'y' must have the same length
这给了我这个输出;
我需要 Billed Hours 列为每个资源名称提供一个 SUM 值,没有名称的第一列工作正常(正如您从重复值中看到的那样),但我无法获得总和计费小时。例如,第一个资源应该有一个空的命名列值 9.75,它确实如此,计费小时数应该是 18 (13+5)。
# Other attempts to achieve this include:
# 1: lapply() within data.table,returns same error as above
result <- DT[,lapply(.SD,cor.test("name2",4:ncol(DT)))]
# 2: mapply(),attempt to repeat the single column to get the same dimensions
result <- mapply(function(x,y) cor.test(x,y,method = c("pearson")),x = cbind(rep(DT[,times = ncol(DT)-3)),y = DT[,4:ncol(DT)])
但这没有用。可能就像以不同的方式放置 SUM 一样简单,但没有一种方法对我有用。
感谢所有帮助。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)