'Anybody else get this error from knn.impute?

I am not sure why but I am getting the following error when applying knn.impute:

Error in storage.mode(use.data) <- "double" : 
  (list) object cannot be coerced to type 'double'

I don`t see anything wrong with the data.

Data:

library(bnstruct)
data(iris)
data <- iris[, 1:4]
data <- prodNA(iris, noNA = 0.2) # generate random missing data
knn.impute(data, k = 10, cat.var = 1:ncol(data),
           to.impute = 1:nrow(data), using = 1:nrow(data))

str(data)

'data.frame':   150 obs. of  4 variables:
 $ Sepal.Length: num  5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
 $ Sepal.Width : num  3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
 $ Petal.Length: num  1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
 $ Petal.Width : num  0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
r


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source