简体   繁体   English

svd(x, nu = 0, nv = k) 中的错误:“x”中的值无限或缺失。 矩阵中没有 NA 或 Inf 值

[英]Error in svd(x, nu = 0, nv = k) : infinite or missing values in 'x'. There are no NA or Inf values in matrix

I checked my matrix for NA, Inf and -Inf.我检查了矩阵的 NA、Inf 和 -Inf。 There are no occurrences.没有发生。 What is happening?怎么了?

head(peaks.new)
           X99     X111     X127      X191      X196     X273      X347      X357      X372     X430      X542      X601      X676      X688     X730
[1,] 0.5804457 1.144064 1.060764 0.3957671 0.4605744 1.395375 0.3997679 0.4058198 0.6135423 1.024926 0.3185467 0.4280903 0.4200074 0.4150762 1.026295
[2,] 0.6738807 1.228152 1.199513 0.4588390 0.5470579 1.383542 0.4491294 0.4576340 0.7606879 1.188590 0.3476853 0.4771873 0.5021612 0.4848465 1.165312
[3,] 0.6315261 1.235551 1.234193 0.4415364 0.5230350 1.514145 0.4512593 0.4589265 0.7238682 1.180188 0.3389439 0.4703305 0.4733625 0.4622625 1.175494
[4,] 0.6482746 1.240872 1.270660 0.5258102 0.5381634 1.430304 0.4888256 0.4987946 0.8740429 1.189461 0.3790521 0.5155980 0.4893849 0.4897720 1.090612
[5,] 0.6110295 1.215108 1.162420 0.4374122 0.4988751 1.435029 0.4320153 0.4360902 0.7144469 1.148086 0.3276657 0.4432349 0.4520939 0.4402073 1.129200
[6,] 0.7070189 1.344910 1.254874 0.4893428 0.5730396 1.708531 0.4627560 0.4797072 0.7752893 1.229642 0.3612133 0.4825547 0.5037152 0.4896373 1.267938

pca.peaks <- prcomp(t(peaks.new), scale=T, retx=T, center=T)
Error in svd(x, nu = 0, nv = k) : infinite or missing values in 'x'


which(peaks.new==0)
integer(0)
> which(peaks.new==Inf)
integer(0)
> which(peaks.new==-Inf)
integer(0)
> which(peaks.new==NA)
integer(0)

NA s are tricky. NA很棘手。 Consider this:考虑一下:

> a = c(1, NA, 2)
> which(a == NA)
integer(0)

> a == NA
[1] NA NA NA

Equality checks with NA will result in NA.与 NA 的平等检查将导致 NA。 The proper way of checking for NAs is with the is.na() function:检查 NA 的正确方法是使用is.na() function:

> is.na(a)
[1] FALSE  TRUE FALSE

There's also is.infinite() for the case of Inf , though in that case direct comparison works (eg (1/0) == Inf yields TRUE ).对于Inf的情况,还有is.infinite() ,尽管在这种情况下直接比较有效(例如(1/0) == Inf产生TRUE )。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 R 中的 PCA:svd(x,nu=0,nv=k)中的错误:“x”中的值无限或缺失 - PCA in R: Error in svd(x, nu=0, nv=k) : Infinite or missing values in 'x' svd(x,nu = 0)中的错误:&#39;x&#39;中的值无限或缺失(检查是否存在负值) - Error in svd(x, nu = 0) : infinite or missing values in 'x' (checked no negative values exist) R - svd()函数 - &#39;x&#39;中的无限或缺失值 - R - svd() function - infinite or missing values in 'x' svd(X)中的错误:&#39;x&#39;中的值无穷或缺失。 在GAS中使用BacktestVaR时 - Error in svd(X) : infinite or missing values in 'x' . when using BacktestVaR in GAS R MASS软件包中的lm.ridge()说“ svd(X)中的错误:&#39;x&#39;中的值无穷或缺失” - lm.ridge() in R MASS package saying “Error in svd(X) : infinite or missing values in 'x'” R:采样:校准函数:svd(X)中的错误:“ x”中的值无穷或缺失 - R: Sampling: Calib function: Error in svd(X) : infinite or missing values in 'x' svd(x,nu = 0)中的错误:0范围尺寸 - Error in svd(x, nu = 0) : 0 extent dimensions La.svd(x, nu, nv) 中的错误:在 ClustOfVar 中使用稳定性函数时,来自 Lapack 例程“dgesdd”的错误代码 1 - Error in La.svd(x, nu, nv) : error code 1 from Lapack routine 'dgesdd' when using stability function in ClustOfVar 计算R错误中的SVD:缺失值或无限值 - Calculate SVD in R error: missing or infinite values 特征(x)中的错误:“x”中的无限值或缺失值 &gt; 在 robumeta 中 - Error in eigen(x) : infinite or missing values in 'x' > in robumeta
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM