Skip to contents

Generates trait rows for hypothetical invaders by resampling the empirical distribution of resident traits. Row names are set to the invader IDs.

Usage

simulate_invaders(
  resident_traits,
  n_inv = 10,
  species_col = "species",
  trait_cols = NULL,
  mode = c("columnwise", "rowwise"),
  numeric_method = c("bootstrap", "normal", "uniform"),
  keep_bounds = TRUE,
  inv_prefix = "inv",
  keep_species_column = TRUE,
  seed = NULL
)

Arguments

resident_traits

data.frame with a species ID column and trait columns.

n_inv

integer; number of invaders to simulate.

species_col

character; species ID column name in resident_traits.

trait_cols

NULL or character; which trait columns to use (default: all except species_col).

mode

"columnwise" (new combinations; default) or "rowwise" (preserve covariance).

numeric_method

for columnwise numeric traits: "bootstrap" (default), "normal", or "uniform".

keep_bounds

logical; constrain normal/uniform draws to observed min,max (default TRUE).

inv_prefix

character; prefix for invader IDs (default "inv").

keep_species_column

logical; keep species ID column after setting row names (default TRUE).

seed

NULL or integer; RNG seed.

Value

data.frame of simulated invaders with row names == species IDs.