PCA在R中以非交互方式结果

时间:2018-01-19 16:07:47

标签: r pca

我发给你一条消息,因为我想在包含ade4的R中实现一个PCA。

我有数据" PAYSAGE" :

enter image description here

所有变量都是数字,PAYSAGE是数据框,没有NAS或空白。

但是当我这样做时:

require(ade4)
ACP<-dudi.pca(PAYSAGE)
2

我收到消息错误:

**You can reproduce this result non-interactively with: 
dudi.pca(df = PAYSAGE, scannf = FALSE, nf = NA)

Error in if (nf <= 0) nf <- 2 : missing value where TRUE/FALSE needed
In addition: Warning message:

In as.dudi(df, col.w, row.w, scannf = scannf, nf = nf, call = match.call(),  :
  NAs introduced by coercion**

我不明白这是什么意思。你知道吗??

非常感谢

2 个答案:

答案 0 :(得分:0)

如果可能的话,我建议共享其他人可以访问的数据集/示例。这似乎是特定于数据的,NAs introduced by coercion您可能需要检查输入的类型 - typeof(PAYSAGE) - dudi.pca的手册指出它将数值的数据框作为输入。< / p>

答案 1 :(得分:0)

是的,例如:

ag_div <- c(75362,68795,78384,79087,79120,73155,58558,58444,68795,76223,50696,0,17161,0,0)
canne <- c(rep(0,10),5214,6030,0,0,0)
prairie_el<- c(60, rep(0,13),76985)
sol_nu <- c(18820,25948,13150,9903,12097,21032,35032,35504,25948,20438,12153,33096,15748,33260,44786)
urb_peu_d <- c(448,459,5575,5902,5562,458,6271,6136,459,1850,40,13871,40,13920,28669)
urb_den <- c(rep(0,12),14579,0,0)
veg_arbo <- c(2366,3327,3110,3006,3049,2632,7546,7620,3327,37100,3710,0,181,0,181)
veg_arbu <- c(18704,18526,15768,15527,15675,18886,12971,12790,18526,15975,22216,24257,30962,24001,14523)
eau <- c(rep(0,10),34747,31621,36966,32165,28054)

PAYSAGE<-data.frame(ag_div,canne,prairie_el,sol_nu,urb_peu_d,urb_den,veg_arbo,veg_arbu,eau)

require(ade4)
ACP<-dudi.pca(PAYSAGE)