View source: R/dataFunctions.R
aggregate_category | R Documentation |
Get count (or frequency) of number of entries per taxon for each category. The return will be a matrix with rows equal to your taxa and columns all possible categories for the focal column, with entries being the number / frequency of records for that taxon for that category
aggregate_category(
locations,
focal = "realm",
group_by = "taxon",
return_frequency = FALSE
)
locations |
Data.frame of locations (i.e., from locality_add_habitat_biome) |
focal |
Column name to aggregate data over. |
group_by |
What column name to use for grouping |
return_frequency |
Boolean; if TRUE, give frequency, not counts |
A matrix of counts or frequencies
locations <- spocc_taxon_query("Bubo", limit=500)
locations <- locality_clean(locations)
locations <- locality_add_habitat_biome(locations)
biome_counts <- aggregate_category(locations, focal="biome", group_by="taxon")
print(head(biome_counts))
realm_frequencies <- aggregate_category(locations, focal="realm", group_by="taxon", return_frequency=TRUE)
print(head(realm_frequencies))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.