sample_by_column {quickcode} | R Documentation |
Re-sample a dataset by column and return number of entry needed
Description
Shorthand to return a re-sample number of rows in a data frame by unique column
Usage
sample_by_column(.dt, col, n, seed = NULL, replace = FALSE)
Arguments
.dt |
data frame to re-sample |
col |
column to uniquely re-sample |
n |
number of rows to return |
seed |
unique numeric value for reproducibility |
replace |
should sampling be with replacement |
Value
data frame containing re-sampled rows from an original data frame
Examples
data1 <- data.frame(ID=1:10,MOT=11:20)
sample_by_column(data1,MOT,3)
sample_by_column(data1,ID,7)
[Package quickcode version 0.9.1 Index]