Package 'proxirr'

Title: Alpha and Beta Proximity to Irreplaceability
Description: Functions to measure Alpha and Beta Proximity to Irreplaceability. The methods for Alpha and Beta irreplaceability were first described in: Baisero D., Schuster R. & Plumptre A.J. Redefining and Mapping Global Irreplaceability. Conservation Biology 2021;1-11. <doi:10.1111/cobi.13806>.
Authors: Daniele Baisero [aut, cre, cph]
Maintainer: Daniele Baisero <[email protected]>
License: MIT + file LICENSE
Version: 0.4
Built: 2025-02-16 04:30:40 UTC
Source: https://github.com/cran/proxirr

Help Index


Calculate Alpha Irreplaceability

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.

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

Usage

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, [email protected]

Examples

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)

Calculate Beta Irreplaceability

Description

This function calculates Beta irreplaceability. Inputs can be either a vector of Alpha values, or a data.frame containing all necessary parameters needed to calculate Alpha values on a row-by-row basis.

  • Vector Beta measurement: If data is a vector of Alpha irreplaceability values, a single Beta value will be calculated and returned.

  • Dataframe Beta measurement: If data is a data.frame and local, global and target are strings representing field names in data, a vector of Alpha irreplaceability values will be caluclated using these fields, and a Beta irreplaceability value will be calculated on these, and returned.

Usage

beta(
  data,
  local = NULL,
  global = NULL,
  target = NULL,
  triage = FALSE,
  na.rm = TRUE
)

Arguments

data

vector or data.frame - The input over which to calculate Beta.

local

string - The name of the column containing the feature's representation at the site. Needed if data is a data.frame

global

string - The name of the column containing the feature's total available representation. Needed if data is a data.frame

target

string - The name of the column containing the feature's target. Needed if data is a data.frame

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

logical - Should lines with missing values (NA) be ignored? If data is a vector, NA values will be removed when calculating Beta. If data is a data.frame, Alpha values will be calculated using alpha with na.allow set to TRUE, and then Beta calculated ignoring NA values.

Value

A number

Author(s)

Daniele Baisero, [email protected]

Examples

beta(c(0.01, 0.5, 0.5))
dtfrm = data.frame(
  loc = c(1,25,45),
  glob = c(100,100,100),
  targ = c(50,50,50)
)
beta(dtfrm, local = 'loc', global = 'glob', target = 'targ')

Marxan: Alpha irreplaceabilities

Description

Given a valid Marxan input.dat file, it returns a copy of the PUVSPRNAME file (puvspr.dat), with additional columns containing the feature's global value, target value, and alpha irreplaceability.

Usage

marxan_alphas(input, triage = FALSE)

Arguments

input

string - The address of the input.dat file.

triage

logical - Should features with unachievable targets be given an irreplaceability of 0? See alpha.

Details

The global value is obtained as the sum of the feature's "amount" column in PUVSPRNAME.

The target value is obtained from the SPECNAME file (spec.dat), either as the proportion of the global value (if the "prop" column is present in SPECNAME), or as the "target" value in SPECNAME (otherwise). This behaviour mirrors Marxan's default behaviour.

Value

A data.frame

Author(s)

Daniele Baisero, [email protected]

Examples

## Not run: 
marxan_alphas('/data/marxan/analysis01/input.dat')
marxan_alphas('C:\data\marxan\analysis01\input.dat')

## End(Not run)

Marxan: Beta irreplaceabilities

Description

Given a valid Marxan input.dat file, returns a copy of the PUNAME file (pu.dat), with an additional column containing the planning unit's beta irreplaceability.

Usage

marxan_betas(input, triage = FALSE)

Arguments

input

string - The address of the input.dat file.

triage

logical - Should features with unachievable targets be given an irreplaceability of 0? See beta.

Value

A data.frame

Author(s)

Daniele Baisero, [email protected]

Examples

## Not run: 
marxan_betas('/data/marxan/analysis01/input.dat')
marxan_betas('C:\data\marxan\analysis01\input.dat')

## End(Not run)

Marxan: Save Alpha and Beta Irreplaceabilities

Description

Saves the outputs of marxan_alphas and marxan_betas in the marxan output folder.

Usage

marxan_run(input, alphas = TRUE, betas = TRUE, triage = FALSE)

Arguments

input

string - The address of the input.dat file.

alphas

logical - Should the Alpha Irreplaceability output be saved?

betas

logical - Should the Beta Irreplaceability output be saved?

triage

logical - Should features with unachievable targets be given an irreplaceability of 0? See alpha and beta.

Details

Two files ('_proxirr_alphas.csv', '_proxirr_betas.csv') will be created prefixed with the scenario name indicated in 'input.dat' ('SCENNAME').

Value

TRUE

Author(s)

Daniele Baisero, [email protected]

Examples

## Not run: 
marxan_run('/data/marxan/analysis01/input.dat')
marxan_run('C:\data\marxan\analysis01\input.dat')

## End(Not run)