Open mhische-md opened 11 years ago
oh, wait...I just saw, this is related to the already closed issue #13 Sorry for that. It just seems, there is only the version 2.0.1 available on CRAN, whereas here you are already at 2.0.3. When will the newer version be available there?
Hi,
in the special case that only 1 row contains missing values, kNNImpute() returns:
"Error in apply(x.missing, 1, function(i) { : dim(X) must have a positive length")
As far as I can see, the sub-function impute.prelim() is responsible in line
prelim = impute.prelim(x)
.If more than 2 rows contain missing, this function returns a matrix for
impute.prelim()$x.missing
. If only 1 row contains missings, it returns a named vector, which later on can not be handled by the apply-functiont(apply(x.missing, 1, function(i) {
My suggestion was to test, if inserting the
drop=FALSE
option at the end of function impute.prelim() solves the problem:if (byrow) x.missing = cbind(1:nrow(x), x)[missing.rows.indices, ,drop=FALSE ] else x.missing = rbind(1:ncol(x), x)[, missing.cols.indices ,drop=FALSE]
Thanks for reading :)