joshwlambert / DAISIEprep

Extracts phylogenetic island community data from phylogenetic trees
https://joshwlambert.github.io/DAISIEprep
GNU General Public License v3.0
6 stars 3 forks source link

Add error message when add species to non-existing clade #30

Closed luislvalente closed 6 months ago

luislvalente commented 9 months ago

When using the function add_missing_species() one can specify which clade to assign it to using: e.g. species_to_add_to = "Plant_e". This works fine. However, I noticed that if I add to as species that is not included in the island_tbl species_to_add_to = "Plant_that_is_not_in_the_islandtbl" the code runs and nothing happens. I think in this case it should give the following error message:

"You are adding species to a clade that is already sampled in the data. However, in species_to_add_to you are giving the name of a species that does not occur in the data, so the clade cannot be located."

joshwlambert commented 6 months ago

Reading back on the code and the testing of this function, letting add_missing_species() work when the species is not on the island was the intended behaviour of the function. However, I agree with you that this should be updated as it could catch out users who think they've added missing species correctly but the function has silently returned the island_tbl without adding the missing species. I will make the change with the suggested error message. Thanks!