I am also dealing with the same problem in principal component analysis in R.The same error message is being shown:
Error in cov.wt(z) : 'x' must contain finite values only
I have checked your answers for this, but still its not working. The user2662565 had the same problem.
This is the program code i have used:
***data<-read.csv(file.choose(),header=T)
data
#Calculate number of rows and col
rows<-length(data[,1])
rows
cols<-length(data[1,])
cols
#Remove header and save each column to a matrix
for ( i in 1:rows){
for ( j in 1:cols){
if(data[i,j]=="NA"){
data[i,j]="0"
}
}
}
pca_a<-princomp(data, cor=True, covmat=NULL, scores=TRUE)
#Print scree plot
require(graphics)
plot(pca_a)
#plot pca
biplot(pca_a)***