The canaper package uses defensive programming extensively (calling assertthat::assert_that), which is generally a very good thing. However, here are some exceptions: The functions calc_biodiv_random and cpr_rand_comm are only called internally and are called thousands of times inside of the loop. It should be save to remove all (most) of the calls to assertthat::assert_that from these functions as parameters have been checked already and are save to use! In fact the algorithm spent a similar amount of time in assertthat::assert_that than computing the biodiversity measures (phylo_endemism, PD).
(note that cpr_rand_comm() is not only called internally, but is also provided as a user-facing (exported) function)
As described by @KlausVigo in his ROpenSci review
(note that
cpr_rand_comm()
is not only called internally, but is also provided as a user-facing (exported) function)