mixture_draw | R Documentation |
Takes a reference dataset and a set of population proportions, either at the collection or reporting unit level. Randomly samples individuals to satisfy these desired proportions, and splits them into a new "mixture" dataframe.
mixture_draw(D, rhos = NULL, omegas = NULL, N, min_remaining = 0)
D |
a two-column genetic dataframe with "indiv", "repunit", and "collection" columns |
rhos |
a vector of the desired reporting unit proportions in the mixture set; if not named, will be assumed to be ordered by order of appearance in the dataset |
omegas |
the desired collection proportions in the mixture set |
N |
the total size of the mixture set |
min_remaining |
the fraction of any collection in the reference dataset which must remain at the end of the draw |
mixture_draw
returns a list of two data frames,
"mixture" being the random sample taken, and "reference" being the remaining samples
rhos <- as.vector(gtools::rdirichlet(1, table(alewife$repunit)))
cross_val <- mixture_draw(D = alewife, rhos = rhos, N = 100, min_remaining = .005)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.