View source: R/script - ransamp.R
Takes a dataframe of individuals (rows) with certain attributes (columns), and samples a given number of individuals from all possible combinations of a given set of paramters For example, can sample one individual of ech combination of sex and age
1 2 3 4 5 6 7 8 9 10 | ransamp(
df_f,
ofEach,
nOfEach,
noShareWithin,
priBy,
usedupl = F,
checkExternal = F,
identifier = ""
)
|
df_f |
The dataframe to work on |
ofEach |
The parameters we want to use, as a vector of column names, e.g: ofEach=c("sex","age","tank") |
nOfEach |
How many individuals within each combination of the "ofEach" parameters that should be selected |
noShareWithin |
one or more sets of paremeters, where unique combinations can't be shared. For example, if we want no more than a single individual from any given family, within a tank, a set would be c("family","tank"), meaning that no individuals can have the same of both family and tank. Supplied within a list, so: list(c("family","tank")). Add more sets within the list if needed, for example: list(c("tank","father"),c("tank","mother))) |
priBy |
If some individuals are to be prioritized over others, specify the name of the column containing prioritization info. This must ba number, and lower numbers are prioritized. (E.g, individuals with "1" are prioritized over individuals iwth "2") |
checkExternal |
... |
identifier |
... |
useDupl |
If all individuals that are selected within each combination may be be used, or just one of them. |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.