key: Generate Dichotomous Key using CONFOR/KEY

View source: R/key.R

keyR Documentation

Generate Dichotomous Key using CONFOR/KEY

Description

This function replicates the KEY command in the DELTA system for generating dichotomous keys. It creates the necessary directives files and runs the CONFOR and KEY programs.

Usage

key(
  delta,
  heading = NULL,
  add_character_numbers = FALSE,
  no_bracketted_key = FALSE,
  no_tabular_key = TRUE,
  number_of_confirmatory_characters = 0,
  treat_characters_as_variable = NULL,
  use_normal_values = NULL,
  character_reliabilities = NULL,
  key_states = NULL,
  abase = 2,
  rbase = 1.4,
  reuse = 1.01,
  varywt = 0.8,
  print_width = 80,
  exclude_items = NULL,
  exclude_characters = NULL,
  remove_temp = TRUE
)

Arguments

delta

A Delta dataset object (created by load_delta)

heading

Heading for the output (default = NULL, uses heading from specs file)

add_character_numbers

Character numbers are to be inserted in bracketed keys (default = FALSE)

no_bracketted_key

Suppresses the production of a key in the conventional, 'bracketed' format (default = FALSE)

no_tabular_key

Suppresses the production of a key in tabular format (default = TRUE)

number_of_confirmatory_characters

Number of confirmatory characters that will be sought for each main character in the key (default = 0, maximum = 4)

treat_characters_as_variable

A list of characters for which particular attributes are to be treated as 'variable' (default = NULL)

use_normal_values

A list of numeric characters for which extreme values are to be ignored and normal values used when translating into other formats (default = NULL)

character_reliabilities

A list of the 'reliabilities' of the characters (default = NULL)

key_states

A list of numeric character states to be divided into ranges for use as states in identification keys (default = NULL)

abase

Sets the base of the logarithmic item abundance scale (default = 2)

rbase

Sets the base of the logarithmic character-reliability scale (default = 1.4)

reuse

Attempt to minimize the number of different characters used in the key (default = 1.01)

varywt

Sets the value of a parameter that determines the treatment of intra-taxon variability in the process of character selection (default = 0.8)

print_width

Maximum line length for output of the keys (default = 80)

exclude_items

A list of items to be excluded (default = NULL)

exclude_characters

A list of characters to be excluded (default = NULL)

remove_temp

Logical; if TRUE, remove temporary files after conversion (default = TRUE)

Details

The function assumes that the CONFOR and KEY program executables are available in the system PATH or in the current working directory.

Value

Invisibly returns the key as a character vector on success

Examples

# Requires the CONFOR and KEY executables on the PATH.

try({
  delta <- load_delta(
    system.file("extdata", "chars_viola", package = "RDelta"),
    system.file("extdata", "items_viola", package = "RDelta"),
    system.file("extdata", "specs_viola", package = "RDelta")
  )
  key(delta)
  key(delta, abase = 2, rbase = 1.4,
      no_tabular_key = TRUE, number_of_confirmatory_characters = 2)
})


RDelta documentation built on Oct. 28, 2026, 5:12 p.m.