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.
Single Alpha measurement: If local, global and
target are numeric, it calculates and returns Alpha irreplaceability.
Vectorized Alpha measurement: If local, global
and target are vectors of the same length, a vector of Alpha
irreplaceability values will be calculated and returned.
Dataframe Alpha measurement: If df is provided and
local, global and target are strings representing
field names in df, a vector of Alpha irreplaceability values will be
caluclated and returned. Optionally: If alpha_col is also
provided, a data.frame identical to df will be returned with
the calculated Alpha values in the alpha_col column.
alpha(
local,
global,
target,
df = NULL,
alpha_col = NULL,
triage = FALSE,
na.allow = NULL,
overwrite = FALSE
)A number, vector or data.frame
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.
number, vector or string - The feature's globally available representation, or the name of the column containing the feature's globally available representation.
number, vector or string - The feature's target, or the name of the column containing the feature's target.
data.frame - Optional; an input data.frame.
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.
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.
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.
logical - Should alpha_col be overwritten if it
already exists?
Daniele Baisero, daniele.baisero@gmail.com
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)
Run the code above in your browser using DataLab