Description Usage Arguments Value Examples
Return a sample from a vector within a grouping variable.
1 | sample_bygroup(x, group, size = NULL, replace = FALSE)
|
x |
any vector |
group |
a grouping vector equal in length to |
size |
the number of items to sample within each group, as a positive
number or a vector of numbers equal in length to the number of groups. If
|
replace |
logical; should sampling be with replacement? |
x
resampled within groups
1 2 3 4 5 6 | set.seed(100)
grvec <- c(rep("a", 3), rep("b", 4), rep("c", 3))
quanteda.core:::sample_bygroup(1:10, group = grvec, replace = FALSE)
quanteda.core:::sample_bygroup(1:10, group = grvec, replace = TRUE)
quanteda.core:::sample_bygroup(1:10, group = grvec, size = 2, replace = TRUE)
quanteda.core:::sample_bygroup(1:10, group = grvec, size = c(1, 1, 3), replace = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.