alpha: Calculate Alpha Irreplaceability

Description Usage Arguments Value Author(s) Examples

View source: R/alphabeta.R

Description

This function calculates Alpha irreplaceability. Inputs can be single parameter values needed to calculate Alpha, vectors of parameter values to calculate a vector of Alpha values, or a data.frame with columns containing parameters needed to calculate a vector of Alpha values.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
alpha(
  local,
  global,
  target,
  df = NULL,
  alpha_col = NULL,
  triage = FALSE,
  na.allow = NULL,
  overwrite = FALSE
)

Arguments

local

number, vector or string - The feature's representation at the site, or the name of the column containing the feature's representation at the site.

global

number, vector or string - The feature's globally available representation, or the name of the column containing the feature's globally available representation.

target

number, vector or string - The feature's target, or the name of the column containing the feature's target.

df

data.frame - Optional; an input data.frame.

alpha_col

string - The name of the column where to write alpha values. If both df and alpha_col are provided, the output will be the input dataframe with the additional column.

triage

logical - Should features with unachievable targets be ignored? Defaults to FALSE. If FALSE, these species will be always assigned an Alpha irreplaceability of 1 wherever they occur. If TRUE, these species will always be assigned an Alpha irreplaceabiltiy of 0.

na.allow

logical - Allaw NA values in input? If TRUE, NA values in local, global or target walues will result in NA being returned, otherwise an error will be raised. Defaults to FALSE for single Alpha calculations, and to TRUE for calculations over vectors or data.frames.

overwrite

logical - Should alpha_col be overwritten if it already exists?

Value

A number, vector or data.frame

Author(s)

Daniele Baisero, daniele.baisero@gmail.com

Examples

1
2
3
4
5
6
7
8
alpha(1, 100, 45)
alpha(c(1,25,45), c(100,100,100), c(50,50,50))
dtfrm = data.frame(
  loc = c(1,25,45),
  glob = c(100,100,100),
  targ = c(50,50,50)
)
alpha('loc', 'glob', 'targ', df = dtfrm)

proxirr documentation built on Nov. 14, 2021, 1:07 a.m.