• Register
1 vote
733 views

Problem :

I am very new to R. I have very recently joined R project team. I can surely say that there are no NA values in the data still I am facing following error for my below written code:

Please find below my code for your reference:

mydata=read.csv("noise.csv")

attach(mydata)

log.dat=log(mydata[,1:5])

dat.sspressure=mydata[,6]

dat.pca=prcomp(log.dat,center=TRUE,scale=TRUE)

Please find below my error for your reference:

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

I have already spent a lot of time in trying to fix above error. So now I am looking for the expert who can suggest quick fix for above error.

8 5 2
3,230 points

Please log in or register to answer this question.

1 Answer

1 vote

Solution :

As per your error wants to suggest that you may have the infinite or the missing values. Your log transformation can cause above error if the original data has really no missing values.

I am trying to explain you the solution with below code example:

> dbdata <- c(-1:3)
> l.dbdata <- log(dbdata)
Warning message:
In log(dbdata) : NaNs produced
> l.dbdata
[1]       NaN      -Inf 0.0000000 0.6931472 1.0986123
> dat.pca=prcomp(l.dbdata,center=TRUE,scale=TRUE)
Error in svd(x, nu = 0, nv = k) : infinite or missing values in 'x'
I hope above solution helped you in saving your time.
8 4
5,680 points

Related questions

0 votes
1 answer 606 views
606 views
Problem: I have only the fundamental knowledge related to R. I want to simulate the very basic moving average process in R which is as shown below for your reference: x_t = Z_(t-1)-0.4Z_(t-2)+Z_t. Please find below my code in R: z = rnorm(500, 0, 1) x ... was unable to find the exact solution for my above error. I am looking for some help from R expert if possible to fix my above R related error.
asked Aug 12, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 62 views
0 votes
1 answer 156 views
0 votes
1 answer 3.2K views
3.2K views
Problem : While I am trying to run the boxcox transformation with the following code urban1 <- subset(ski,urban <= 4,na.rm=TRUE) ski$gender <- as.numeric((as.character(ski$gender)),na.rm=TRUE) urban1 <- as.numeric((as.character(urban1))) a <- (ski$gender*urban1) ... -> boxcar -> boxcar.formula -> lm -> lm.fit Execution halted Please let me know if anyone knows the solution for this error message.
asked Nov 27, 2019 alecxe 7.5k points
1 vote
1 answer 204 views
204 views
Problem: I have very fundamental knowledge of logistic regression. I am trying to write code on logistic regression. I have done a lot of research on this issue but because of my limited knowledge I am still unable to fix the below error. Error ... (data) stock.direction <- data$Direction training_model=glm(stock.direction~data$lag2,data=data,family=binomial) Please help me in fixing above error.
asked May 26, 2020 Martin K 6.6k points
0 votes
1 answer 895 views
895 views
Problem : I am trying to merge data in R but facing following error error in fix.by(by.x, x) : 'by' must specify one or more columns as numbers, names or logical
asked Nov 15, 2019 peterlaw 6.9k points
0 votes
1 answer 10 views
10 views
Problem: number of rows in use has changed: remove missing values?
asked Feb 23 Ethan ross 1.9k points
0 votes
1 answer 16 views
16 views
problem Missing values are not allowed in subscripted assignments of data frames.
asked Feb 9 charles mathews 3.9k points
0 votes
1 answer 2K views
2K views
Problem : I am trying to predict probabilities in a dataset by using glmnet but facing following issue cholmod error 'x and/or y have wrong dimensions' at file ../matrixops/cholmod_sdmult.c, line 90
asked Nov 13, 2019 peterlaw 6.9k points
0 votes
1 answer 131 views