-1

So I run PCA on my data and always find this error: Error in svd(x, nu = 0) : infinite or missing values in 'x'

I've removed the NAs, removed the duplicated rows, but I still get the error

log.neur <- log(neur[, 2:65])
neu.pca <- prcomp(log.neur,
             center = TRUE,
             scale. = TRUE) 

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

akrun
  • 874,273
  • 37
  • 540
  • 662
Lucia
  • 615
  • 1
  • 9
  • 16
  • 1
    Can you provide a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – akrun Aug 15 '15 at 12:33

1 Answers1

1

This is most likely caused by Inf values left in your data, as the typical usage of na.rm = TRUE does not account for this.

The following commands should get things working:

log.neur <- log(neur[, 2:65])
log.neur[!is.finite(log.neur)] = -1 # baseline value
neu.pca <- prcomp(log.neur, center = TRUE, scale. = TRUE) 

where I have arbitrarily set a value of -1 in place of the missing/invalid data. You might have to change that based on how the data looks like

tguzella
  • 1,441
  • 1
  • 12
  • 15