fviz_pca_ind(dat.pca,
+ geom.ind = "point", # show points only (nbut not "text")
+ col.ind = dat4$group_list1, # color by groups
+ palette = c("#00AFBB", "#E7B800"),
+ addEllipses = TRUE, # Concentration ellipses
+ legend.title = "Groups"
+ )
Error in ans[ypos] <- rep(yes, length.out = len)[ypos] :
replacement has length zero
In addition: Warning message:
In rep(yes, length.out = len) : 'x' is NULL so the result will be NULL
搜索了相关报错,没有太大借鉴意义,主要是自己也不太明白这段代码的含义,所以无从下手。
每一行代码依次检查元素,发现之前group_list1导入过程中反复出错,试了很多次,最后导入成功那版改为了a,所以可能在dat4中无法检索到group_list1。但环境中存在group_list1。试一下a。
fviz_pca_ind(dat.pca,
+ geom.ind = "point", # show points only (nbut not "text")
+ col.ind = dat4$a, # color by groups
+ palette = c("#00AFBB", "#E7B800"),
+ addEllipses = TRUE, # Concentration ellipses
+ legend.title = "Groups"
+ )
成功。