powered by
Shorthand to return a re-sample number of rows in a data frame by unique column
sample_by_column(.dt, col, n, seed = NULL, replace = FALSE)
data frame containing re-sampled rows from an original data frame
data frame to re-sample
column to uniquely re-sample
number of rows to return
unique numeric value for reproducibility
should sampling be with replacement
data1 <- data.frame(ID=1:10,MOT=11:20) sample_by_column(data1,MOT,3) sample_by_column(data1,ID,7)
Run the code above in your browser using DataLab