Learn R Programming

taxlist (version 0.3.5)

reindex: Re-index elements of taxlist objects

Description

The assignment of new identifiers must take into account all possible occurrences of such indices in taxlist objects in order to maintain their validity.

Usage

reindex(object, ...)

# S3 method for taxlist reindex(object, old, new, idx = "TaxonConceptID", ...)

reindex(object, ...) <- value

# S3 method for taxlist reindex(object, ...) <- value

Value

An object of class taxlist with modified identifiers.

Arguments

object

A taxlist object.

...

Further arguments to be passed among methods.

old

A vector with old identifiers to be re-indized. This may contain all identifiers or only a part of them. If only a part, the rest of indices will be preserved. If the changes insert duplicated identifiers, an error message will be retrieved. If missing, all identifiers in 'object' will be considered.

new, value

A vector with the new identifiers. It has to be of the same length as 'old'.

idx

Name of the index to be changed, which means "TaxonConceptID", "TaxonUsageID", or "ViewID" for taxon concepts, taxon usage names, or taxon views, respectively. You can also use the aliases "concept", "usage", and "view".

Examples

Run this code
## Copy taxonomic list
sp_list <- Easplist
summary(sp_list, "papyrus")

## Re-index taxon concepts
reindex(sp_list) <- id_generator(nrow(sp_list@taxonRelations),
    mode = "character")

## Re-index taxon usage names
reindex(sp_list, idx = "TaxonUsageID") <- id_generator(nrow(sp_list@taxonNames),
    mode = "character")

## Re-index taxon views
reindex(sp_list, idx = "ViewID") <- id_generator(nrow(sp_list@taxonViews),
    mode = "character")

## Check result
validObject(sp_list)
summary(sp_list, "papyrus")

Run the code above in your browser using DataLab