org_matrix: Organize rows and columns of a matrix

Description Usage Arguments Value Examples

View source: R/org_matrix.R

Description

Organize rows and columns of a matrix

Usage

1
org_matrix(m, method = "alpha")

Arguments

m

A matrix with individuals ordered identically in rows and columns.

method

The method to be used to reorganize the matrix. method="alpha" is the default and will organize rows/columns based on alphanumeric order of rownames/colnames. method="wins" will return a matrix ordered in descending order of summed rows (i.e. total competitive interactions won). If rows have tied number of total wins, they will be returned in the order of the inputted matrix. method="ds" Will return a matrix ordered by David's Score.

Value

The same matrix m with reordered rows/columns

Examples

1
2
3
org_matrix(bonobos)
org_matrix(mouse, method="wins")
org_matrix(people, method="ds")

Example output

   De  Dz He  Ho Ki Lu
De NA  30 18   0  4  0
Dz  0  NA  0   0  1  0
He  1   2 NA   0  0  0
Ho  3   6  0  NA  4  5
Ki 84 122 85  50 NA 10
Lu  8  19 19 267  1 NA
  J H  K  F G I C L B D A E
J 0 4 25 15 3 1 6 6 8 2 5 7
H 7 0 14  6 2 5 4 5 7 4 4 5
K 1 2  0  9 5 4 6 2 5 1 1 2
F 0 0  3  0 2 0 2 1 0 2 0 0
G 1 0  0  0 0 0 1 2 2 1 1 0
I 0 0  3  0 1 0 0 0 2 1 0 1
C 0 0  0  1 1 1 0 1 2 1 0 0
L 0 2  1  2 0 0 0 0 1 0 0 0
B 0 0  0  0 0 1 1 0 0 1 1 0
D 0 0  0  1 1 0 1 1 0 0 0 0
A 0 0  0  0 2 0 0 0 0 1 0 0
E 0 0  0  0 0 0 0 0 1 0 0 0
      Chris Adam Bryan Eddie Derek Frank
Chris     0   11    32    14    36    52
Adam      4    0    33    14    43    26
Bryan     0    5     0     3    11    28
Eddie     6   11     0     0    30     9
Derek     3    1     4    23     0    16
Frank    12   25     9    11     2     0

compete documentation built on May 29, 2017, 1:39 p.m.