我尝试从 vegan
包中进行 CA 分析。
以下是我使用的代码:
install.packages("vegan")
library(vegan)
plots <- c("plotA", "plotB", "plotC", "plotD", "plotE")
animal1 <- c(2,7,4,8,1)
animal2 <- c(4,3,7,1,0)
animal3 <- c(8,5,0,1,3)
animal4 <- c(2,2,9,5,2)
animal5 <- c(1,6,9,8,7)
animalData <- data.frame (plots, animal1, animal2, animal3, animal4, animal5)
attach(animalData)
animalData.ca <- cca(animalData)
但是,我总是遇到一个错误:
我知道标签是一个因子,如果我删除第一列,分析就会起作用。但是,然后分析创建自己的标签,我不能使用我的标签。有没有办法将我的标签(plotA、plotB等)包括进去?Error in rowSums(X) : 'x'必须是数字
data.frame
选项中的row.names
,通过?data.frame
查找。 - liuminzhao