+ if (!is.data.frame(x) && !is.matrix(x))
+ stop("'x' should be a matrix or a data.frame")
+ method <- match.arg(method, c("pairwise", "percentage"))
+
+ if (!pairwise.deletion) {
+ ## delete the columns with at least one NA:
+ del <- apply(x, 2, function(xx) any(is.na(xx)))
+ x <- x[, !del]
+ }
+ n <- dim(x)
+ L <- n[2]
+ n <- n[1]
+ D <- double(n*(n - 1)/2)
+ if (pairwise.deletion) L <- D
+ k <- 1