tabinate: Apply function to TAxon/BIN subset of occurrences and iterATE

View source: R/tabinate.R

tabinateR Documentation

Apply function to TAxon/BIN subset of occurrences and iterATE

Description

The function takes another function and reruns it on every taxon- and/or bin-specific subsets of an occurrence dataset.

Usage

tabinate(x, bin = NULL, tax = NULL, FUN = NULL, ...)

Arguments

x

(data.frame) Fossil occurrence table.

bin

(character) Variable name of the bin numbers of the occurrences. This variable should be numeric.

tax

(character) Variable name of the occurring taxa (variable type: factor or character - such as "genus"

FUN

(function) The function applied to the subset of occurrences. The subset of occurence data will be passed to this function as x.

...

arguments passed to FUN

Details

The main tabinate function acts as a wrapper for any type of function that requires a subset of the occurrence dataset that represents either one bin or one tax entry or both. For example, the iterator can be used to calculate geographic ranges from occurrence coordinates (georange).

The output structure of FUN should be independent from the input subset, or the function will return an error. Setting both bin If bin=NULL and codetax=NULL, will run FUN on the entire dataset (no effect). Providing either bin or tax and keeping the other NULL will iterate FUN for every bin or tax entry (whichever is presented). The function returns a vector of values if the return value of FUN is a single value. In case it is a vector, the final output will be a matrix. When both bin and tax is presented, the function output will be a matrix (one output value for a taxon/bin subset) or an array (3d, when FUN returns a vector). Setting FUN to NULL will return the occurrence dataset as lists.

Value

The return object depends on the output of FUN, as well as the bin and tax input.

Examples

 data(corals)

# the number of different coordinate pairs in every time slice
  tabinate(corals, bin="stg", FUN=georange, lat="paleolat", 
    lng="paleolng", method="co")
# geographic range (site occupancy) of every taxon in every bin
  tabinate(corals, bin="stg", tax="genus", FUN=georange, 
    lat="paleolat", lng="paleolng", method="co")


adamkocsis/divDyn documentation built on Sept. 12, 2022, 9:18 p.m.