diff --git a/src/robitax.c b/src/robitax.c index 8445e3e..2c505e1 100644 --- a/src/robitax.c +++ b/src/robitax.c @@ -622,7 +622,12 @@ SEXP R_is_under_taxon(SEXP Rtaxonomy, SEXP Rtaxid, SEXP Rparent) prep[i]=NA_LOGICAL; else { taxon = eco_findtaxonbytaxid(ptax, ptaxid[i]); - prep[i] = eco_isundertaxon(taxon, parent); + if (taxon) { + prep[i] = eco_isundertaxon(taxon, parent); + } + else { + prep[i]=NA_LOGICAL; + } } } }