[R] PCA - "cov.wt(z) : 'x' must contain finite values only"

Ravi Varadhan rvaradhan at jhmi.edu
Tue Dec 18 19:51:40 CET 2007

The problem is the missing values.  The argument "na.action" is not active
in princomp(), which I think is a bug, even though the help page claims that
"factory fresh" default is na.omit.

So, you need to either get rid of the rows with any missing values in them,
or use a PCA code that can deal with missing values by somehow imputing



Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvaradhan at jhmi.edu

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html



-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Johnson, Bethany 
Sent: Tuesday, December 18, 2007 1:14 PM
To: r-help at r-project.org
Subject: [R] PCA - "cov.wt(z) : 'x' must contain finite values only"

I am trying to run PCA on a matrix (the first column and row are
headers).  There are several cells with NA's.  When I run PCA with the
following code:
AsianProp<-read.csv("Matrix.csv", sep=",", header=T, row.names=1)
AsianProp.pca<-princomp(AsianProp, na.omit)

I get the error message:

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

What am I doing wrong?  

Thanks very much!

	[[alternative HTML version deleted]]

R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list