[英]R - Infinite or missing values in 'x'
I'm getting Error in svd(x, nu = 0L, nv = 0L) : infinite or missing values in 'x'
when trying to calculate SVD for a 100x2 matrix in an R script. 我
Error in svd(x, nu = 0L, nv = 0L) : infinite or missing values in 'x'
遇到Error in svd(x, nu = 0L, nv = 0L) : infinite or missing values in 'x'
尝试在R脚本中为100x2矩阵计算SVD时Error in svd(x, nu = 0L, nv = 0L) : infinite or missing values in 'x'
。 What's funny is that doing the exact same thing for the exact same matrix in the R prompt works perfectly. 有趣的是,对R提示符中的完全相同的矩阵执行完全相同的操作非常有效。
These are the data: 这些是数据:
[,1] [,2]
[1,] 5840 5
[2,] 5840 6
[3,] 14600 2
[4,] 5840 5
[5,] 5840 4
[6,] 5840 5
[7,] 14600 5
[8,] 14600 8
[9,] 5840 5
[10,] 262144 11
[11,] 66240 5
[12,] 16560 14
[13,] 5840 5
[14,] 5840 17
[15,] 16560 6
[16,] 5840 7
[17,] 66240 5
[18,] 5840 7
[19,] 33003 7
[20,] 65535 7
[21,] 5840 6
[22,] 65535 7
[23,] 65535 4
[24,] 16560 4
[25,] 5840 4
[26,] 14600 9
[27,] 65535 6
[28,] 14600 8
[29,] 8192 8
[30,] 14600 5
[31,] 14600 5
[32,] 131072 8
[33,] 14600 10
[34,] 14600 5
[35,] 14600 5
[36,] 14600 5
[37,] 14600 5
[38,] 14600 8
[39,] 8192 9
[40,] 8192 16
[41,] 65535 5
[42,] 14600 5
[43,] 6432 5
[44,] 14600 5
[45,] 5840 5
[46,] 14600 5
[47,] 8192 7
[48,] 254992 5
[49,] 14600 6
[50,] 5840 7
[51,] 14600 5
[52,] 5840 6
[53,] 16560 7
[54,] 64860 6
[55,] 14600 5
[56,] 14600 5
[57,] 14600 5
[58,] 14600 5
[59,] 14600 5
[60,] 14600 5
[61,] 5840 5
[62,] 65535 4
[63,] 14600 5
[64,] 14600 5
[65,] 14600 8
[66,] 131328 5
[67,] 5840 5
[68,] 14600 5
[69,] 14600 5
[70,] 14600 5
[71,] 14600 5
[72,] 14600 5
[73,] 14600 5
[74,] 5840 19
[75,] 14600 5
[76,] 5840 5
[77,] 14600 5
[78,] 14600 5
[79,] 14600 5
[80,] 14600 5
[81,] 14600 5
[82,] 14600 5
[83,] 5840 7
[84,] 14600 5
[85,] 66048 21
[86,] 65535 159
[87,] 6432 6
[88,] 14600 5
[89,] 65535 5
[90,] 8192 10
[91,] 5840 5
[92,] 14600 5
[93,] 14600 5
[94,] 66048 8
[95,] 14600 5
[96,] 16560 5
[97,] 14600 5
[98,] 42900 6
[99,] 8192 7
[100,] 8192 7
I'm using a subset of the columns, so the actual call I'm making is svd(C[,1:i])
where C
is the matrix I'm using and i
equals 2 when this crashes. 我使用的是列的子集,所以我进行的实际调用是
svd(C[,1:i])
,其中C
是我正在使用的矩阵,当崩溃时i
等于2。
I'm positive that the matrices in the script and in the prompt are the same (I printed them both to different files and diffed them out to make sure!) 我肯定脚本和提示中的矩阵是相同的(我将它们都打印到了不同的文件中,并进行了对比以确保结果!)
So, what could be the problem here? 那么,这可能是什么问题?
EDIT 编辑
dput(C[,1:i])
structure(c(5840, 5840, 14600, 5840, 5840, 5840, 14600, 14600,
5840, 262144, 66240, 16560, 5840, 5840, 16560, 5840, 66240, 5840,
33003, 65535, 5840, 65535, 65535, 16560, 5840, 14600, 65535,
14600, 8192, 14600, 14600, 131072, 14600, 14600, 14600, 14600,
14600, 14600, 8192, 8192, 65535, 14600, 6432, 14600, 5840, 14600,
8192, 254992, 14600, 5840, 14600, 5840, 16560, 64860, 14600,
14600, 14600, 14600, 14600, 14600, 5840, 65535, 14600, 14600,
14600, 131328, 5840, 14600, 14600, 14600, 14600, 14600, 14600,
5840, 14600, 5840, 14600, 14600, 14600, 14600, 14600, 14600,
5840, 14600, 66048, 65535, 6432, 14600, 65535, 8192, 5840, 14600,
14600, 66048, 14600, 16560, 14600, 42900, 8192, 8192, 5, 6, 2,
5, 4, 5, 5, 8, 5, 11, 5, 14, 5, 17, 6, 7, 5, 7, 7, 7, 6, 7, 4,
4, 4, 9, 6, 8, 8, 5, 5, 8, 10, 5, 5, 5, 5, 8, 9, 16, 5, 5, 5,
5, 5, 5, 7, 5, 6, 7, 5, 6, 7, 6, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5,
8, 5, 5, 5, 5, 5, 5, 5, 5, 19, 5, 5, 5, 5, 5, 5, 5, 5, 7, 5,
21, 159, 6, 5, 5, 10, 5, 5, 5, 8, 5, 5, 5, 6, 7, 7), .Dim = c(100L,
2L))
Relates to error message of OP , not to specific context of OP. 与OP的错误消息有关,而不与OP的特定上下文有关。
Error in svd(X, nu = 0L) : infinite or missing values in 'x' svd(X,nu = 0L)中的错误:“ x”中的值无穷或缺失
Occurs when calculating LDA .. 在计算LDA时发生..
If the explained variable / group only has one value in the data supplied ( invalid data ). 如果所解释的变量/组在提供的数据中只有一个值(无效数据)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.