variety: Variety or Richness

Description Usage Arguments Value Examples

View source: R/diversity.R

Description

Computes the variety (number of distinct types) or simple diversity of an entity. It is also known as richness.

Usage

1
variety(data, sort = TRUE, decreasing = TRUE, category_row = FALSE)

Arguments

data

A numeric matrix with entities i in the rows and categories j in the columns. Cells show the respective value (value of abundance) of entity i in the category j. It can also be a transpose of the previous matrix, that is, a matrix with categories in the rows and entities in the columns. Yet in that case, the argument "category_row" has to be set to TRUE. The matrix must include names for the rows and the columns. The argument "data", also accepts a dataframe with three columns in the following order: entity, category and value.

sort

Indicates whether results should be ordered or not. Define it to FALSE to avoid ordering.

decreasing

If argument "sort" is set to TRUE, this argument indicates descending order. The default value is TRUE.

category_row

A flag to indicate that categories are in the rows. The analysis assumes that the categories are in the columns of the matrix. If the categories are in the rows and the entities in the columns, then the argument "category_row" has to be set to TRUE. The default value is FALSE.

Value

A dataframe with values of variety for each entity.

Examples

1
2

Example output

Loading required package: proxy

Attaching package:proxyThe following objects are masked frompackage:stats:

    as.dist, dist

The following object is masked frompackage:base:

    as.matrix

Loading required package: reshape2
Loading required package: foreign
             variety
Canada            27
China             24
South Africa      16
Portugal          11
Latvia            10
New Zealand        9
Chile              7
Saudi Arabia       7
Uruguay            4
Vietnam            4
             variety
Canada            27
Chile              7
China             24
Latvia            10
New Zealand        9
Portugal          11
Saudi Arabia       7
South Africa      16
Uruguay            4
Vietnam            4

diverse documentation built on May 2, 2019, 2:10 a.m.

Related to variety in diverse...