valentinitnelav / bootstrapnet

R package for bootstrapping indices of bipartite ecological networks
https://valentinitnelav.github.io/bootstrapnet/
MIT License
5 stars 2 forks source link

Throw error message when wrong index is provided #3

Closed valentinitnelav closed 5 years ago

valentinitnelav commented 5 years ago

When using a species level index (e.g betweenness) as index in boot_networklevel (or boot_networklevel_n, boot_networklevel_once) it still tries to compute something. It should break the code with error message.

I think has to do with how I set the try in boot_networklevel_once, because networklevel(Safariland_sort, index = "betweenness", level = "both") throws an error. That error should be passed to boot_networklevel_n, which should pass it to boot_networklevel.

Note that, this will stand valid for the species level functions as well.

valentinitnelav commented 5 years ago

A fast fix would be to run a test of bipartite::networklevel or specieslevel at the beginning of boot_networklevel or boot_specieslevel so that any error message will stop the execution and inform the user. The cost is that this adds unnecessary computation time to already expensive functions... Alternatively take the testing section from the bipartite functions and make a test function that is triggered at the top (?).

valentinitnelav commented 5 years ago

Also this problem can't be solved by .errorhandling = 'pass' in foreach (which I set anyways with commit 79d757f53225dd784a33370ce047e4bda363637e )