Skip to contents

atlas_counts supports server-side grouping of data. Grouping can be used to return record counts grouped by multiple, valid fields (found by search_fields. Use galah_group_by when using the group_by argument of atlas_counts to return record counts summed by one or more valid fields.

Usage

galah_group_by(..., expand = TRUE)

Arguments

...

zero or more individual column names to include

expand

logical: When passed to group_by argument of atlas_counts, should factor levels be expanded? Defaults to TRUE.

Value

If any arguments are provided, returns a data.frame with columns name and type, as per galah_select(); if no arguments are provided, returns NULL.

Examples

Return record counts since 2010 by year

records <- galah_call() |> 
    galah_filter(year > 2010) |>
    galah_group_by(year) |>
    atlas_counts()

records
#> # A tibble: 12 x 2
#>    year    count
#>    <chr>   <int>
#>  1 2020  5843340
#>  2 2019  5506924
#>  3 2018  5418009
#>  4 2017  4648403
#>  5 2016  3844787
#>  6 2014  3767573
#>  7 2015  3605917
#>  8 2013  3505658
#>  9 2012  2933981
#> 10 2011  2539004
#> 11 2021  1161557
#> 12 2022    41790

Return record counts since 2010 by year and data provider

records <- galah_call() |>
    galah_filter(year > 2010) |>
    galah_group_by(year, dataResourceName) |>
    atlas_counts()

records
#> # A tibble: 1,048 x 3
#>   year  dataResourceName              count
#>   <chr> <chr>                         <int>
#> 1 2020  eBird Australia             4589800
#> 2 2020  iNaturalist Australia        671032
#> 3 2020  NSW BioNet Atlas             372617
#> 4 2020  Earth Guardians Weekly Feed   71783
#> # ... with 1,044 more rows

Return record counts of Litoria species each year since 2015, limiting results to the top 5 each year

records <- galah_call() |>
    galah_identify("Litoria") |>
    galah_filter(year > 2015) |>
    galah_group_by(year, species) |>
    atlas_counts(limit = 5)

records
#> # A tibble: 35 x 3
#>   year  species            count
#>   <chr> <chr>              <int>
#> 1 2018  Litoria peronii    10497
#> 2 2018  Litoria fallax      7013
#> 3 2018  Litoria caerulea    3073
#> 4 2018  Litoria verreauxii  2980
#> # ... with 31 more rows

See also