AtlasOfLivingAustralia / galah-R

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

`show_values()` formats output (which isn't compatible with `galah_filter()`) #233

Closed daxkellie closed 5 months ago

daxkellie commented 7 months ago

The output of show_values() appears to be formatted after it is retrieved, which makes it look nice, but if you use the values shown by the output of show_values() for the field basisOfRecord, your query won't work.

search_all(fields, "basisOfRecord") |> show_values()
#> ! Search returned 2 matched fields.
#> • Showing values for 'basisOfRecord'.
#> # A tibble: 9 × 1
#>   basisOfRecord      
#>   <chr>              
#> 1 Human observation  
#> 2 Preserved specimen 
#> 3 Observation        
#> 4 Occurrence         
#> 5 Machine observation
#> 6 Material Sample    
#> 7 Living specimen    
#> 8 Material Citation  
#> 9 Fossil specimen

galah_call() |>
  identify("Daviesia ulicifolia") |>
  filter(basisOfRecord == "Human observation") |>
  atlas_counts()
#> # A tibble: 1 × 1
#>   count
#>   <int>
#> 1     0

The actual values for basisOfRecord are in all caps and separated by an underscore, which when used, return the correct result.

galah_call() |>
  identify("Daviesia ulicifolia") |>
  filter(basisOfRecord == "HUMAN_OBSERVATION") |>
  atlas_counts()
#> # A tibble: 1 × 1
#>   count
#>   <int>
#> 1 14446

Created on 2024-03-06 with reprex v2.0.2

I'm not sure whether this is true for all show_values() results, and whether it is the same for search_values() as well.