A friend recently asked:
"Does anybody know how to, in R, select a single tree at random from a posterior distribution of trees (e.g., generated via MrBayes)?"
This is not too hard. A set of trees read into memory using read.tree or read.nexus is just a list of trees with the class attribute set to "multiPhylo". To pick one at random we can just do:
If we want to sample more than one, say 100 random trees from a posterior sample of 1,000, the procedure is the same. So we can just do: