我有一个数据矩阵(900列和5000行),我想要做一个pca ..如何将变量变为定量?
该矩阵看起来非常好在Excel中(意味着所有的值都是定量的),但在我读我的文件在R中,并尝试运行pca代码,我得到一个错误,说“下面的变量不是定量的”,我得到一个非定量变量列表。
所以一般来说,一些变量是定量的,有些不是。 请参阅以下示例。 当我检查变量1时,它是正确和定量的..(随机的一些变量在文件中是定量的) 当我检查变量2时,它是不正确的和非定量的..(随机一些像这样的变量是非 - 定量在文件中)
> data$variable1[1:5]
[1] -0.7617504 -0.9740939 -0.5089303 -0.1032487 -0.1245882
> data$variable2[1:5]
[1] -0.183546332959017 -0.179283451229594 -0.191165669598284 -0.187060515423038
[5] -0.184409474669824
731 Levels: -0.001841783473108 -0.001855956210119 ... -1,97E+05
所以我的问题是,我怎么能将所有的非定量变量转化为定量?
缩短文件并没有帮助,因为这些值本身就是定量的。我不知道发生了什么事。 所以这里是我的原始文件链接< - https://docs.google.com/file/d/0BzP-YLnUNCdwakc4dnhYdEpudjQ/edit
我也试过下面给出的答案,但它仍然没有帮助。
那么让我告诉正是我做了什么,
> data <- read.delim("file.txt", header=T)
> res.pca = PCA(data, quali.sup=1, graph=T)
Error in PCA(data, quali.sup = 1, graph = T) :
The following variables are not quantitative: batch
The following variables are not quantitative: target79
The following variables are not quantitative: target148
The following variables are not quantitative: target151
The following variables are not quantitative: target217
The following variables are not quantitative: target266
The following variables are not quantitative: target515
The following variables are not quantitative: target530
The following variables are not quantitative: target587
The following variables are not quantitative: target620
The following variables are not quantitative: target730
The following variables are not quantitative: target739
The following variables are not quantitative: target801
The following variables are not quantitative: target803
The following variables are not quantitative: target809
The following variables are not quantitative: target819
The following variables are not quantitative: target868
The following variables a
In addition: There were 50 or more warnings (use warnings() to see the first 50)
我可能是错的,但我怀疑97E + 05做的伎俩。检查包含诸如非数字之类的东西的条目。您是否以CSV格式导出? – 2013-02-28 09:58:26
@ sebastian-c我现在删除文件中的所有值与“E”(如-1,97E + 05)..我仍然得到相同的错误..我把它导出为“文本制表符分隔”..另一件事情是,检查变量1和变量2的差异。量化变量很短,非定量变量很长。 – Letin 2013-02-28 10:08:06
您的数据如何从Excel转换为R?这是你在变量2中的一个因素。 – themel 2013-02-28 10:09:08