Error in svd(x, nu = 0, nv = k) : infinite or missing values in 'x'
I am using prcomp()
and got this error message. I tried to do a reprex but could not reproduce the error. I tried:
df[is.na(df)] <- 0##NA values to 0
df <-df[which(rowSums(df) > 0),]##rm rows with only zeros
df <- df[, colSums(df != 0) > 0]##rm cols with only zeros
df
is a data.frame, that is a list
and not numeric
. I have run out of ideas! What else could I try?
While most of it looks right, one thing that might help out here, is to change how you check for zero-columns. In this matter it is better to check
length(unique(x))
or possibly bettervar(x) < 10^-13
(X almost doesn't vary, so it has almost only 1 value).