Harsh Patil
Harsh Patil

Reputation: 11

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

There are no NA values in my data, though im still getting this error for the following code:

my_data=read.csv("airfoil_self_noise.csv")
attach(my_data)
log.dat=log(my_data[,1:5])
dat.sspressure=my_data[,6]
dat.pca=prcomp(log.dat,center=TRUE,scale=TRUE)

error:

dat.pca=prcomp(log.dat,center=TRUE,scale=TRUE) Error in svd(x, nu = 0, nv = k) : infinite or missing values in 'x'

Upvotes: 1

Views: 5953

Answers (1)

You-leee
You-leee

Reputation: 560

As the error says, you have infinite or missing values. The log transformation can cause this, if your original data has no missing ones.

For example:

> data <- c(-1:3)
> l.data <- log(data)
Warning message:
In log(data) : NaNs produced
> l.data
[1]       NaN      -Inf 0.0000000 0.6931472 1.0986123
> dat.pca=prcomp(l.data,center=TRUE,scale=TRUE)
Error in svd(x, nu = 0, nv = k) : infinite or missing values in 'x'

Upvotes: 0

Related Questions