Learn R Programming

galah (version 2.1.2)

group_by.data_request: Group by one or more variables

Description

Most data operations are done on groups defined by variables. group_by() takes a field name (unquoted) and performs a grouping operation. The default behaviour is to use it in combination with count() to give information on number of occurrences per level of that field. Alternatively, you can use it without count to get a download of occurrences grouped by that variable. This is particularly useful when used with a taxonomic ID field (speciesID, genusID etc.) as it allows further information to be appended to the result. This is how atlas_species() works, for example. See select() for details.

Usage

# S3 method for data_request
group_by(.data, ...)

galah_group_by(...)

Value

If any arguments are provided, returns a data.frame with columns name and type, as per select.data_request().

Arguments

.data

An object of class data_request

...

Zero or more individual column names to include

Examples

Run this code
if (FALSE) {
# default usage is for grouping counts
galah_call() |> 
  group_by(basisOfRecord) |>
  counts() |>
  collect()

# Alternatively, we can use this with an occurrence search  
galah_call() |>
  filter(year == 2024,
         genus = "Crinia") |>
  group_by(speciesID) |>
 collect()
# note that this example is equivalent to `atlas_species()`; 
# but using `group_by()` is more flexible.
}

Run the code above in your browser using DataLab