Learn R Programming

mateable (version 0.3.1)

overlap: Pairwise Mating Timing Comparison

Description

Get comparisons of mating timing between all pairs

Usage

overlap(scene, overlapOrTotal = c("overlap", "total"),
  compareToSelf = FALSE)

Arguments

scene
a matingScene object
overlapOrTotal
whether to calculate the number of days that each pair was overlapping in mating receptivity or the total number of days that either individual was receptive
compareToSelf
whether or not to include self comparisons in the return value

Value

  • a matrix containing all pairwise comparisons. If compareToSelf is FALSE then there will be n rows and n-1 columns. To index result[i,j] where j > i, use result[i,j-1], where result is the return value of overlap. There is one attribute "idOrder" which holds the order of the id column in scene at the time of the function call. This can be useful to find certain elements in the matrix (see examples). If scene is a multi-year matingScene, then overlap will return a list of matrices (as described above) where each matrix represents one year.

Examples

Run this code
pop <- simulateScene()
pop <- pop[order(pop$start),]
daysSync <- overlap(pop)
indices <- which(attr(daysSync, "idOrder") %in% c(1, 4))
if (indices[1] <= indices[2]) {
  daysSync[indices[1], indices[2]]
} else {
  daysSync[indices[1], indices[2]-1]
}

Run the code above in your browser using DataLab