# filling out NA values using clustering analysis

I have a data frame with a large number of NA values. I do not wish to leave out all these rows as that would reduce the size of my training set drastically.

I filled out these missing values in a couple of ways, such as

1. Filling the NA values in a column with the majority value in that column
2. Filling the NA values with a random label from that column.

However, I would like to try out something which uses cluster analysis. Is there an R package which allows this? Two things which I can implement are as follows

1. Finding the k nearest neighbour and filling up the missing/NA value as the majority of the k neighbours. However, this could be difficult because running the knn itself required that the rows don't have NA values, in the first place.
2. Finding the jaccard similarity based on other columns in the row, and filling up the missing/NA value with the corresponding value from the jaccard similar row.

Finding jaccard match

library(stringdist) df[which.min(Reduce(+,Map(stringdist,df, newdata, method='jaccard'))),]


Please suggest me a package/library in R which will help me fill out the missing/NA values using cluster analysis.

• I use the mice package in these cases. – mace Apr 1 '15 at 21:54