# Dealing with NA values while using Rotation Forest in R

I am using Rotation Forest in r. I have a very big list (which I can't give a sample) that has 50 attributes and 4000 rows. for every row there is a few missing values in the attributes, it supposed to be like that and I cant fill the missing values.

this is my code:

y <- list[,1]
x <- list[,2:ncol(list)]
rF <- rotationForest(x,y,K = round(ncol(x)/3),L=15)


this is the error:

Error in cov.wt(z) : 'x' must contain finite values only


from what I gathered the problem is with NA in relevance to PCA in the rotation forest.

any suggestion on what I can do?

• could you try any(is.na(x))? Jan 5 '17 at 11:08
• I know I have na, this code shows if I have NA isn't it?
– anat
Jan 5 '17 at 12:20
• it does, you should remove the NA's to make sure that rotationForest() works, according to the error message. Jan 5 '17 at 12:51
• like I said, I have "NA" as an empty cell, I cant remove it because to every row has a few empty cells and it supposed to be like that,
– anat
Jan 5 '17 at 21:32
• PCA cannot handle missing values so you will have to see if you can substitute the missing values with, for example, the mean or the median of the attribute. But in any case the question will then be how to correctly fill missing values so you can apply PCA. Jan 5 '17 at 22:20