Loop function over all trees in object of class 'multiphylo'
I wish to run some analyses on all the trees that come as output in the BEAST run. Most of the functions say they can be run only on the objects of class 'phylo'. For example - functions in the package 'laser'. I am trying to use a for loop and iterating over all the objects in multiphylo. For eg, to fit a birth-date model
library(laser)
f=read.nexus(file.choose())
bdmodel<-0
for(i in 1:length(f))
{
bdmodel[i]<-bd(branching.times(trees[[i]]), ai = seq(0.05, 0.99, length.out = 20))
print(usq[i])
}
print(i)
Is there a better way of doing this? I wish to iterate particular operations on all the trees in the multiphylo object and get output for each single tree.
• 2,587 views
•
link
0 answers
No answers yet.
Log in to answer this question.