VectorSample: Randomize a binary vector

Description Usage Arguments Value Author(s) References Examples

View source: R/VectorSample.R

Description

This function is used by Gotelli's matrix randomization functions. It takes an input binary vector and a weight vector of equal length and reassigns 1s randomly in proportion to the weights.

Usage

1

Arguments

v

A binary vector

w

A vector of sampling weights; length equal to length of v.

Value

A randomized binary vector.

Author(s)

Nicholas J. Gotelli. Help edited by John Quensen.

References

Gotelli, N. J. 2000. Null model analysis of species co-occurrence patterns. Ecology 81:2606-2621.

Examples

1
2
3
sam <- sample(c(1,0), 10, replace=TRUE)
wt <- rep(1, 10) # Equal sampling probablilities.
random.sam <- VectorSample(sam, wt)

jfq3/QsNullModels documentation built on April 6, 2020, 2:06 p.m.