我有一個數據矩陣(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