dot-flipdyads: flip dyads in (0,1) table

.flipdyadsR Documentation

flip dyads in (0,1) table

Description

flip dyads in 0/1 matrix to randomize data set

Usage

.flipdyads(x, x.dates, flips, presence = NULL, pr.dates = NULL, x.fo = NULL)

Arguments

x

data frame with association data

x.dates

Date, dates corresponding to rows in x (x.dates=), i.e. of same length as rows of x, and corresponding to presence (pr.dates=)

flips

numeric, how many flips to perform

presence

presence matrix; see createnullpresence

pr.dates

Date, dates corresponding to rows in x (x.dates=), i.e. of same length as rows of x, and corresponding to presence (pr.dates=)

x.fo

character string corresponding to rows in x with focal animal IDs, if supplied, focal animals are excluded from flipping, i.e. focals remain in their party/association

Value

a table with the same dimensions as x, except that the date column is removed if there was one in x when it was supplied to the function.

References

Whitehead 2008; Bejder et al 1998

Examples

## Not run: 
data(dolphins)
# create a presence table (all being present all the time)
dpres <- createnullpresence(colnames(x)[2:19], from="2000-01-01", "2000-02-09")
# without presence
colSums(flipdyads(dolphins, 10))
# with presence
colSums(flipdyads(dolphins, 10, dolphins$Date, presence))

dolphins[,-1] - flipdyads(dolphins, 10)
sum(abs(dolphins[,-1] - flipdyads(dolphins, 20)))

## End(Not run)

gobbios/socialindices documentation built on Feb. 14, 2023, 3:56 p.m.