View source: R/perm-comb-my-sample.R
my_sample | R Documentation |
Functions to determine the number of possible ways to choose a sample with/without replacement where order does and does not matter.
Without replacement, if the order doesn't matter then we have a combination, if the order do matter then we have a permutation. One could say that a permutation is an ordered combination.
my_sample(n, k, replace = TRUE, ordered = TRUE)
perm(n, k)
comb(n, k)
n |
total number of objects in the set; an integer. |
k |
number of choosing objects from the set; an integer |
replace |
Logical indicating with or without replacement; default is
|
ordered |
Logical indicating ordered or unordered; default is
|
A numeric value.
https://www.mathsisfun.com/combinatorics/combinations-permutations.html
perm(15, 2)
comb(15, 2)
# same as comb(15, 2)
my_sample(n = 15,
k = 2,
replace = FALSE,
ordered = FALSE)
# same as perm(15, 2)
my_sample(n = 15,
k = 2,
replace = FALSE,
ordered = TRUE)
my_sample(n = 15,
k = 2,
replace = TRUE,
ordered = TRUE)
my_sample(n = 15,
k = 2,
replace = TRUE,
ordered = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.