registry_for_seriaiton_methods {seriation} | R Documentation |
Registry for Seriation Methods
Description
A registry to manage methods used by seriate()
.
Usage
registry_seriate
list_seriation_methods(kind, names_only = TRUE)
get_seriation_method(kind, name)
set_seriation_method(
kind,
name,
definition,
description = NULL,
control = list(),
randomized = FALSE,
optimizes = NA_character_,
verbose = FALSE,
...
)
## S3 method for class 'seriation_method'
print(x, ...)
Arguments
kind |
the data type the method works on. For example, |
names_only |
logical; return only the method name. |
name |
the name for the method used to refer to the method in
|
definition |
a function containing the method's code. |
description |
a description of the method. For example, a long name. |
control |
a list with control arguments and default values. |
randomized |
logical; does the algorithm use randomization and re-running
the algorithm several times will lead to different results (see: |
optimizes |
what criterion does the algorithm try to optimize
(see: |
verbose |
logical; print a message when a new method is registered. |
... |
further information that is stored for the method in the registry. |
x |
an object of class "seriation_method" to be printed. |
Format
An object of class seriation_registry
(inherits from registry
) of length 57.
Details
The functions below are convenience function for the registry
registry_seriate
.
list_seriation_method()
lists all available methods for a given data
type (kind
) (e.g., "dist", "matrix").
The result is a vector of character strings with the
method names that can be used in function seriate()
.
If kind
is missing, then a list of
methods is returned.
get_seriation_method()
returns detailed information for a given method in
form of an object of class "seriation_method"
.
The information includes a description, parameters and the
implementing function.
With set_seriation_method()
new seriation methods can be added by the
user. The implementing function (definition
) needs to have the formal
arguments x, control
and, for arrays and matrices margin
,
where x
is the data object and
control
contains a list with additional information for the method
passed on from seriate()
, and margin
is a vector specifying
what dimensions should be seriated.
The implementation has to return a list of
objects which can be coerced into ser_permutation_vector
objects
(e.g., integer vectors). The elements in the list have to be in
corresponding order to the dimensions of x
.
Value
-
list_seriation_method()
result is a vector of character strings with the names of the methods. These names are used for methods inseriate()
. -
get_seriation_method()
returns a given method in form of an object of class"seriation_method"
.
Author(s)
Michael Hahsler
See Also
This registry uses registry::registry.
Other seriation:
register_DendSer()
,
register_GA()
,
register_optics()
,
register_smacof()
,
register_tsne()
,
register_umap()
,
seriate()
,
seriate_best()
Examples
# Registry
registry_seriate
# List all seriation methods by type
list_seriation_methods()
# List methods for matrix seriation
list_seriation_methods("matrix")
get_seriation_method(name = "BEA")
# Example for defining a new seriation method (reverse identity function for matrix)
# 1. Create the seriation method
# (with margin since it is for arrays; NA means no seriation is applied)
seriation_method_reverse <- function(x, control = NULL,
margin = seq_along(dim(x))) {
lapply(seq_along(dim(x)), function(i)
if (i %in% margin) rev(seq(dim(x)[i]))
else NA)
}
# 2. Register new method
set_seriation_method("matrix", "Reverse", seriation_method_reverse,
description = "Reverse identity order", control = list())
list_seriation_methods("matrix")
get_seriation_method("matrix", "reverse")
# 3. Use the new seriation methods
seriate(matrix(1:12, ncol=3), "reverse")