0
我有三個目錄,每個目錄中有五個文件。這些文件是矩陣(柵格)。我想計算文件相應列之間的迴歸方程。爲什麼在R中使用lm.fit時,df.residual會返回「邏輯」?
fun <- function(x1, x2, y) {
keep <- !(is.na(x1) | is.na(x2) | is.na(y))
if (sum(keep) > 1) {
res <- lm.fit(cbind(1,x1[keep], x2[keep]), y[keep])$df.residual
} else {
res <- c(NA, NA, NA)
}
res
}
res <- array(res, dim=c(1,dim(dat1)[2:3])); res <- aperm(res, c(2,3,1))
res
# [1,] Logical,3 Logical,3 Logical,3 Logical,3 Logical,3 Logical,3 Logical,3 Logical,3 Logical,3
# Logical,3 Logical,3 Logical,3
如果您不會說法語,您的下載鏈接將毫無用處。你應該教育自己如何創建一個**最小**可重現的例子。 – Roland