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
- Filling the NA values in a column with the majority value in that column
- 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
- 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.
- 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.