Willard
Willard

Reputation: 522

R PCA Analysis Error

I get the following error when running a PCA analysis in R and can't figure out what's wrong with my data:

Error in svd(x, nu = 0) : infinite or missing values in 'x'

load(url("https://dl.dropboxusercontent.com/u/48336796/data/Y.RData"))
pca <- prcomp(Y, center = FALSE, scale = FALSE, na.action = na.omit)

I made sure to replace all NA's in the matrix with zeros. I also checked the matrix for infinity. Can somebody please help me understand what's wrong.

Upvotes: 0

Views: 245

Answers (1)

Richard Telford
Richard Telford

Reputation: 9923

You appear to be trying to run a PCA on character data

typeof(Y)
[1] "character"

That is not going to work. Either convert to numeric values with

Y[] <- as.numeric(Y)

Or fix the import step.

A warning that the data object is huge (>200 MB) would have been appreciated.

Upvotes: 1

Related Questions