Description Usage Arguments Examples
View source: R/data.table_misc.R
Return a random sample of row ids (by grouping)
1 2 |
sort |
1 2 3 4 5 6 7 8 9 10 11 12 13 | set.seed(2016)
size <- 10
dt <- data.table(
id = 1:size, A = sample(letters[1:3], size, replace = TRUE), B = 'N',
C = sample(1:100, size, replace = TRUE) + sample(30:70, size, replace = TRUE))
set.seed(2016)
sample_ids(dt, 0.5, grouping = 'A')
set.seed(2016)
sample_ids(dt, 0.5, grouping = 'A', sort = TRUE)
set.seed(2016)
sample_ids(dt, 0.5, grouping = 'A', return_grouping = TRUE)
set.seed(2016)
sample_ids(dt, 0.5, grouping = 'A', sort = TRUE, return_grouping = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.