Skip to content

group_by() doesn't work with atlas_counts (type = "species") #284

@mjwestgate

Description

@mjwestgate

This works:

galah_call() |>
    filter(year == 2025) |>
    atlas_counts(type = "species")
# A tibble: 1 × 1
  count
  <int>
1 35292

But this doesn't:

galah_call() |>
    filter(year == 2025) |>
    group_by(cl22) |>
    atlas_counts(type = "species")
Error in `dplyr::bind_cols()` at galah-R/R/collect_species_count.R:9:5:
! Can't recycle `..1` (size 11) to match `..2` (size 3).
Run `rlang::last_trace()` to see where the error occurred.

This could be viewed as a simple bug, but there might be a deeper problem here in that recent versions use group_by(speciesID) as equivalent to atlas_species(). This leads to a problem where we are effectively using group_by() twice, to do different things:

  • once to tell us the number of categories present (species)
  • another to give the levels of categories (states and territories)

Given that these are distinct operations, this suggests that group_by() isn't solely the solution, and something more dplyr-like might be needed to distinguish them. Not sure what that looks like rn but might involve summarise.data_request() or similar.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions