plot_ranks: Plot the ranking of individuals

Description Usage Arguments Details Value Author(s) References Examples

View source: R/plot_ranks.R

Description

Function to plot the ranking of individuals in different ways.

Usage

1
2
plot_ranks(ranks, plot.CIs = FALSE, ordered.by.rank = TRUE, 
	identities = NULL, plot.identities = TRUE, colors = NULL)

Arguments

ranks

Either a vector containing the score or rank of each individual, or an NxK matrix containing the results of K randomisations of the data.

plot.CIs

Boolean (TRUE/FALSE): if providing an NxK matrix, then setting plot.CIs to TRUE will plot the 95% range of the scores or ranks given for each individual.

ordered.by.rank

Boolean (TRUE/FALSE) describing whether to order individuals by rank or not.

identities

A vector containing the identity (name) of each individual to be plotted along the X axis.

plot.identities

Boolean (TRUE/FALSE) describing whether to plot the identity of each individual along the X axis.

colors

A vector containing the colour for each individual (default="black"). This is useful for example to colour individuals by sex.

Details

A simple function that plots individuals' ranks, with options to colour individuals or order them. Here the y axis is reverse, so that rank=1 occurs at the top.

Value

Generates a plot. No data is returned.

Author(s)

Written by Damien R. Farine & Alfredo Sanchez-Tojar

Maintainer: Damien R. Farine <damien.farine@ieu.uzh.ch>

References

Sanchez-Tojar, A., Schroeder, J., Farine, D.R. (in prep) Methods for inferring dominance hierarchies and estimating their uncertainty.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
	
	# Set population size 
	N <- 10

	# Set shape parameters
	a = 15
	b = 3

	# Generate data
	data <- generate_interactions(N,100,a,b)

	# Extract data (and turn IDs into letters for this example)
	winners <- letters[data$interactions$Winner]
	losers <- letters[data$interactions$Loser]
	identities <- letters[data$hierarchy$ID]
	
	# Calculate Elo scores
	scores <- elo_scores(winners,losers,identities=identities,randomise=TRUE)
	
	# Plot results
	plot_ranks(scores, plot.CIs=TRUE,identities=TRUE,colors=rainbow(N))
	

Example output



aniDom documentation built on March 7, 2021, 1:07 a.m.