Documentation for SLiM function sampleIndividuals, which is a method of the SLiM class Subpopulation. Note that the R function is a stub, it does not do anything in R (except bring up this documentation). It will only do anything useful when used inside a slim_block function further nested in a slim_script function call, where it will be translated into valid SLiM code as part of a full SLiM script.

sampleIndividuals(
  size,
  replace,
  exclude,
  sex,
  minAge,
  maxAge,
  migrant,
  tagL0,
  tagL1,
  tagL2,
  tagL3,
  tagL4
)

Arguments

size

An object of type integer. Must be of length 1 (a singleton). See details for description.

replace

An object of type logical. Must be of length 1 (a singleton). The default value is F. See details for description.

exclude

An object of type null or Individual object. Must be of length 1 (a singleton). The default value is NULL. See details for description.

sex

An object of type null or string. Must be of length 1 (a singleton). The default value is NULL],[Ni$ tag = NULL. See details for description.

minAge

An object of type null or integer. Must be of length 1 (a singleton). The default value is NULL. See details for description.

maxAge

An object of type null or integer. Must be of length 1 (a singleton). The default value is NULL. See details for description.

migrant

An object of type null or logical. Must be of length 1 (a singleton). The default value is NULL. See details for description.

tagL0

An object of type null or logical. Must be of length 1 (a singleton). The default value is NULL. See details for description.

tagL1

An object of type null or logical. Must be of length 1 (a singleton). The default value is NULL. See details for description.

tagL2

An object of type null or logical. Must be of length 1 (a singleton). The default value is NULL. See details for description.

tagL3

An object of type null or logical. Must be of length 1 (a singleton). The default value is NULL. See details for description.

tagL4

An object of type null or logical. Must be of length 1 (a singleton). The default value is NULL. See details for description.

Value

An object of type Individual object.

Details

Documentation for this function can be found in the official SLiM manual: page 743.

Returns a vector of individuals, of size less than or equal to parameter size, sampled from the individuals in the target subpopulation. Sampling is done without replacement if replace is F (the default), or with replacement if replace is T. The remaining parameters specify constraints upon the pool of individuals that will be considered candidates for the sampling. Parameter exclude, if non- NULL, may specify a specific individual that should not be considered a candidate (typically the focal individual in some operation). Parameter sex, if non-NULL, may specify a sex ("M" or "F") for the individuals to be drawn, in sexual models. Parameter tag, if non-NULL, may specify a tag property value for the individuals to be drawn. Parameters minAge and maxAge, if non-NULL, may specify a minimum or maximum age for the individuals to be drawn, in nonWF models. Parameter migrant, if non-NULL, may specify a required value for the migrant property of the individuals to be drawn (so T will require that individuals be migrants, F will require that they not be). Finally, parameters tagL0, tagL1, tagL2, tagL3, and tagL4, if non-NULL, may specify a required value (T or F) for the corresponding properties (tagL0, tagL1, tagL2, tagL3, and tagL4) of the individuals to be drawn. Note that if any tag/tagL parameter is specified as non-NULL, that tag/tagL property must have a defined value for every individual in the subpopulation, otherwise an error may result (although this requirement will not necessarily be checked comprehensively by this method in every invocation). If the candidate pool is smaller than the requested sample size, all eligible candidates will be returned (in randomized order); the result will be a zero-length vector if no eligible candidates exist (unlike sample()). This method is similar to getting the individuals property of the subpopulation, using operator [] to select only individuals with the desired properties, and then using sample() to sample from that candidate pool. However, besides being much simpler than the equivalent Eidos code, it is also much faster, and it does not fail if less than the full sample size is available. See subsetIndividuals() for a similar method that returns a full subset, rather than a sample.

Author

Benjamin C Haller (bhaller@benhaller.com) and Philipp W Messer (messer@cornell.edu)