我试图在多个系统发育树(类multiphylo的文件)上运行函数。这些函数中的大多数都带有特定的R包,但仅适用于单树(class phylo)。从本质上讲,multiphylo对象由类phylo的许多对象组成。我试图看看是否使用for lopp,我可以对multiphylo对象中的所有对象运行相同的操作,但我遇到了错误。有什么建议?
library(ape)
library(TreePar)
x=read.nexus(file.choose()) #read in file with multiple phylogenetic trees
times<-0
for(i in 1:length(x))
{
times[i]<-getx(x[[i]])
print(times[i])
}
print(i)
我收到以下错误警告 -
In ages[i] = getx(x[[i]]) : number of items to replace is not a multiple of replacement length