GioBo / TR8

R package for downloading functional traits data for plant species
20 stars 7 forks source link

NAs not assigned when certain taxon names are supplied #54

Closed Alectoria closed 8 years ago

Alectoria commented 8 years ago

The tr8() function produces an error rather than assigning NA when running these lines:

tr8(species_list = "Crepis",  download_list = "li_form_B")
tr8(species_list = "Equisetum",  download_list = "li_form_B")

In both cases, I get "Error in if (.Object@url == "not present") { : argument is of length zero"

I thought that single-names could be a problem but this works well:

tr8(species_list = "Abies",  download_list = "li_form_B")

 li_form_B
 Abies        NA

Working with v. 0.9.13.

GioBo commented 8 years ago

Thanks for reporting this. TR8 works only with complete "Genus+species" names; the reason for the mentioned inconsistent behavior is due not to Biolflor or TR8, but to the fact that Bioflor names are checked using the taxize package: for Crepis genus there are multiple Biolflor names which are matched by taxize ("mathedname" in taxize terminology) only at the Genus level, thus the tr8() function attempts (without success) to get data from multiple entries: but does not know how to handle that, so the mentioned Error is raised. For Abies genus there is only one species in Biolflor (A. alba), thus tr8() tries to get data from there, and manage to include NA in the data retrieval: this is undesired side-behavior, so I'll add a "Warning" so that users will be advised to use only names at the species level. G.

Alectoria commented 8 years ago

OK, thanks for the explanation. I also bumped into a species+genus name that had the same issue ("Rubus bertramii"), possibly because it is matched by taxize to multiple names.

At the end, I found the following taxon names to produce this error: c("Crepis", "Equisetum", "Fragaria","Potentilla","Ranunculus","Rosa" ,"Rubia", "Rubus","Rubus bertramii", "Salix", "Viola"). Would it be possible to transform cases where multiple matches are found to "NA" or (+1 matches). This way, a process that involves a high number of taxon names would not be stopped.

Really like your package and found it very useful for my work!

GioBo commented 8 years ago

The current version of the package should now behave in the suggested way (NA are used for "Genus-only" entries): for BiolFlor, only original names are used (so that any ambiguity is removed). The new version of tr8() has the optional argument "synonyms": when set to TRUE, tr8 search requested data for both the original names and potential synonyms (found using taxize). A new release (v. 0.9.14) - which corresponds to the github one - has just been uploaded to CRAN. P.S.: if you know of other tratibases which are free to use and could be "potential sources" of data for TR8, please let me know.

Alectoria commented 8 years ago

Thanks @GioBo! Your package was very helpful, even with this minor bug. Looking forward to trying out the new version.