R/sample_from_datasets.R

sample_from_datasets

Samples elements at random from the datasets in datasets.

Description

Samples elements at random from the datasets in datasets.

Usage

 
sample_from_datasets( 
  datasets, 
  weights = NULL, 
  seed = NULL, 
  stop_on_empty_dataset = TRUE 
) 

Arguments

Arguments Description
datasets A list ofobjects with compatible structure.
weights (Optional.) A list of length(datasets) floating-point values where weights[[i]] represents the probability with which an element should be sampled from datasets[[i]], or a dataset object where each element is such a list. Defaults to a uniform distribution across datasets.
seed (Optional.) An integer, representing the random seed that will be used to create the distribution.
stop_on_empty_dataset If TRUE, selection stops if it encounters an empty dataset. If FALSE, it skips empty datasets. It is recommended to set it to TRUE. Otherwise, the selected elements start off as the user intends, but may change as input datasets become empty. This can be difficult to detect since the dataset starts off looking correct. Defaults to TRUE.

Value

A dataset that interleaves elements from datasets at random, according to weights if provided, otherwise with uniform probability.