Xper3 (and its desktop predecessor Xper2) keep a knowledge base of taxa
("items") described by characters ("descriptors"). Their documented
interchange format is SDD: export the knowledge base as SDD from Xper, and
import an SDD file written by writeXper() there. Xper's own storage
format is not publicly specified, so dimoose does not try to read or write
it; these two functions read and write the SDD dialect that Xper
produces.
Usage
readXper(file, taxon = "Taxon", sep = "/", inapplicable = NA, strict = TRUE)
writeXper(
x,
file,
characters = NULL,
taxon = "Taxon",
title = NULL,
sep = "/",
inapplicable = NULL,
lang = "en"
)Arguments
- file
Path of the SDD file to read or write.
- taxon
Name of the taxon column of the matrix.
- sep
Separator between the states of a variable taxon in one cell.
- inapplicable
For readers, the cell value to give "not applicable" (default
NA, the same as unknown). For writers, the cell value that means "not applicable" (defaultNULL: none).- strict
If
TRUE, stop when the file does not say it was generated by Xper.- x
A character matrix (data frame), or the list returned by
readSDD(),readDELTA(),readLucid()orreadXper().- characters
Optional data frame describing the characters: a
Charactercolumn matching the matrix's column names and any ofType,States(to fix the order of the states or list states no taxon has),Unit,InapplicableIfandCost. By default taken fromxifxis a reader's result; otherwise numeric columns are written as numeric characters and all others as categorical ones.- title
Title of the dataset; by default the
titlein the metadata ofx.- lang
Language of the labels, as an
xml:langcode.
Value
readXper() returns the same tdwgData list as readSDD();
writeXper() returns file, invisibly.
Details
Compared with plain readSDD(), the Xper dialect has a few habits that
are handled here: Xper2 names each taxon in the label of its coded
description rather than in a taxon list; the dependencies between
characters are InapplicableIf rules in a single character tree; and
every coding carries an observation-convenience rating, which is read as
the character's Cost (1 = easy to 5 = hard). readXper() stops if the
file was not written by Xper, unless strict = FALSE.
References
Vignes-Lebbe, R., Chesselet, P. & Diep Thi, M.-H. (2016). Xper3: new tools for collaborating, training and transmitting knowledge on botanical phenotypes. In: Botanists of the twenty-first century, UNESCO. https://www.xper3.fr/
Examples
f <- system.file("extdata", "tdwg", "felids-xper3.sdd.xml", package = "dimoose")
d <- readXper(f)
d$matrix
#> Taxon Coat pattern Shape of the spots Claws
#> 1 Panthera leo plain <NA> fully retractile
#> 2 Panthera tigris striped <NA> fully retractile
#> 3 Panthera pardus plain/spotted rosettes fully retractile
#> 4 Acinonyx jubatus spotted solid spots semi-retractile
#> Mane in adult males
#> 1 present
#> 2 absent
#> 3 absent
#> 4 <NA>
d$characters[, c("Character", "InapplicableIf", "Cost")]
#> Character InapplicableIf Cost
#> 1 Coat pattern 1
#> 2 Shape of the spots Coat pattern=plain/striped 3
#> 3 Claws 4
#> 4 Mane in adult males 2
out <- writeXper(d, tempfile(fileext = ".sdd.xml"))
identical(readXper(out)$matrix, d$matrix)
#> [1] TRUE