Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in getting distribution data for species endemic to a single region #53

Closed
wajra opened this issue Jun 29, 2020 · 3 comments
Closed
Labels

Comments

@wajra
Copy link

wajra commented Jun 29, 2020

I was testing the packages using a few species native to Sri Lanka and I consistently ran into the same issue. It appears that when a species is endemic to a single region, 'rcites::spp_distributions' doesn't return a valid value.
I've illustrated the issue below.
If we take the 'Red Slender Loris' (Loris tardigradus), a Loris species native to the rainforests of Sri Lanka and try to get it's distribution, the package throws an error.

library(rcites)

rcites::set_token("YOUR_TOKEN")

# Check for the Sri Lankan Slender Loris
loris <- rcites::spp_taxonconcept("Loris tardigradus")

# Get the species ID
loris_id <- loris$all_id$id

# Get the species distribution
loris_distribution <- rcites::spp_distributions(taxon_id=loris_id)

The error is as follows

Error in apply(tmp[, !colnames(tmp) %in% c("tags", "references")], 2, : dim(X) must have a positive length

However, if we take the Asian Elephant (Elephas maximus), which is found across several Asian regions, there is no such error.

elephant <- rcites::spp_taxonconcept("Elephas maximus")

elephant_id <- elephant$all_id$id

elephant_distribution <- rcites::spp_distributions(taxon=elephant_id)

Thank you for your time. I hope this issue is solvable or I made an honest mistake.

@KevCaz
Copy link
Member

KevCaz commented Jun 30, 2020

Confirmed. Thanks for the report and the reprex, very much appreciated. I am now investigating this.

@KevCaz
Copy link
Member

KevCaz commented Jun 30, 2020

@wajra it should be ok now

R> # Check for the Sri Lankan Slender Loris 
   loris <- rcites::spp_taxonconcept("Loris tardigradus") 
    
   # Get the species ID 
   loris_id <- loris$all_id$id 
    
   # Get the species distribution 
   loris_distribution <- rcites::spp_distributions(taxon_id=loris_id)                                                                                         
→ Retrieving info from page 1 ........................✔
→ Now processing taxon_id '10000'.....................✔

R> loris_distribution                                                                                                                                         

── Distributions ($distributions): ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
     id iso_code2      name    type tags
1 40386        LK Sri Lanka COUNTRY     

── References ($references): ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
     id                        reference
1 40386 Brandon-Jones, D., E [truncated]
2 40386 Eisenberg, J. F. and [truncated]
3 40386 Gamage S., Liyanage, [truncated]
4 40386 Nekaris, K. A. I. an [truncated]
5 40386 Petter, J.-J. and Hl [truncated]
6 40386 Phillips, W. W. A. 1 [truncated]

you'd need to use the dev version for some time, but I am planning on releasing a patched version on CRAN soon. Again thanks for the report. Let me know if everything is working on your side, so I can close 😄 !

@wajra
Copy link
Author

wajra commented Jun 30, 2020

Hello Kevin,

I just installed the dev version and the issue appears to be fixed. Thank you very much for being so quick to respond.

Thanks again.
Kind regards
Jeewantha Bandara

@wajra wajra closed this as completed Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants