Learn R Programming

marinespeed (version 0.1.0)

lapply_species: Apply a function over a set of species

Description

lapply_species returns a list where each element is the result of applying fun to all species or the provided subset of species.

Usage

lapply_species(fun, ..., species = NULL, raw = FALSE)

Arguments

fun
function. The function to be applied to the occurrence records of each species. Parameters are the species name and a dataframe with the occurrence records.
...
optional arguments to fun.
species
dataframe or character vector. Dataframe like returned by list_species or the names of the species. If NULL (default) then fun is applied for all species.
raw
logical. If FALSE then 25 square kilometer grid and manual outlier filtered occurrence records are returned.

Value

A list with one named entry for every species provided or for all species.

Details

The parameters passed to fun are speciesname and data, which is a dataframe with the occurrence records and their environmental data.

See Also

list_species lapply_kfold_species get_occurrences lapply_kfold_species, get_occurrences, list_species

Examples

Run this code
## Not run: ------------------------------------
# get_occ_count <- function(speciesname, occ) {
#  nrow(occ)
# }
# 
# record_counts <- lapply_species(get_occ_count)
# sum(unlist(record_counts))
# 
# # count first 10
# species <- list_species()
# lapply_species(get_occ_count, species=species[1:10,])
## ---------------------------------------------

Run the code above in your browser using DataLab