lapply_species: Apply a function over a set of species

Description Usage Arguments Details Value See Also Examples

View source: R/lapply.R

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

1
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.

Details

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

Value

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

See Also

list_species lapply_kfold_species get_occurrences

lapply_kfold_species, get_occurrences, list_species

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## 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,])

## End(Not run)

samuelbosch/marinespeed documentation built on Dec. 17, 2019, 11:47 p.m.