AtlasOfLivingAustralia / galah-R

Query living atlases from R
https://galah.ala.org.au
38 stars 3 forks source link

`atlas_species` returns error when no species are returned #190

Closed daxkellie closed 1 year ago

daxkellie commented 1 year ago

When there are no species returned in a query to atlas_species(), an error is returned

galah_call() |>
  galah_identify("eolophus") |>
  galah_filter(cl1048 == "Kimberley") |>
  atlas_species()
#> Error in `result[, wanted_columns("checklist")]`:
#> ! Can't subset columns that don't exist.
#> ✖ Columns `kingdom`, `phylum`, `class`, `order`, `family`, etc. don't exist.

This breaks any possible loops that might be run to get multiple species lists

Ideally, this should work the same as atlas_counts() which returns a tibble of 0 rows and 0 columns

galah_call() |>
  galah_identify("eolophus") |>
  galah_filter(cl1048 == "Kimberley") |>
  atlas_counts()
#> # A tibble: 1 × 1
#>   count
#>   <int>
#> 1     0
mjwestgate commented 1 year ago

closed as complete