# A function that computes the time to MRCA of a tree using the
# ape package
mrca.age=function(tree)
{
return(coalescent.intervals(tree)$total.depth)
}
# Read in the settings; Must change the RunName so that the example files can be found
filename=system.file("Examples/example_g_pars",package="Rsampletrees")
runpars=readArgs(filename, check=FALSE)
runname=paste(system.file(package="Rsampletrees"),runpars$RunName, sep="/")
runpars=changeArgs(runpars, RunName=runname)
# Read in the output and add the summary statistic
results=readOutput(runpars)
results=addTreeStat(results, myfunc=mrca.age, funcname="Time to MRCA")
Run the code above in your browser using DataLab