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

From: Ravi Varadhan <rvaradhan_at_jhmi.edu>
Date: Tue, 18 Dec 2007 13:51:40 -0500

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 them.

Ravi.



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:



setwd("I:/PCA")
AsianProp<-read.csv("Matrix.csv", sep=",", header=T, row.names=1) attach(AsianProp)
AsianProp
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
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 18 Dec 2007 - 18:59:36 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 18 Dec 2007 - 20:30:19 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.