I am trying to make a PCA on a data frame with 5,000 columns and 30 rows
Sample <- read.table(file.choose(), header=F,sep="\t") Sample.scaled <- data.frame(apply(Sample,2,scale)) pca.Sample <- prcomp(Sample.scaled,retx=TRUE)`
Error received
Error in svd(x, nu = 0) : infinite or missing values in 'x' sum(is.na(Sample)) [1] 0 sum(is.na(Sample.scaled)) [1] 90
Tried to ignore all na values ββusing the following
pca.Sample <- prcomp(na.omit(Sample.scaled),retx=TRUE)
What gives the following error
Error in svd(x, nu = 0) : 0 extent dimensions
There have been reports that na.action requires a formula to be given, and therefore tried below
pca.Sample <- prcomp(~.,center=TRUE,scale=TRUE,Sample, na.action=na.omit)
Now we get the following error
Error in prcomp.default(x, ...) : cannot rescale a constant/zero column to unit variance
Think that the problem may be that βone of my data columns is constant. The variance of the constant is 0, and the scaling is divisible by 0, which is impossible.β
But not sure how to handle this. Any help is much appreciated ....