Re-sample a dataset by column and return number of entry needed
Source:R/sample_by_column.R
sample_by_column.Rd
Shorthand to return a re-sample number of rows in a data frame by unique column
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
Examples
data1 <- data.frame(ID=1:10,MOT=11:20)
sample_by_column(data1,MOT,3)
#> Warning: Work on function still in progress. Use with caution.
#> ID MOT
#> 2 2 12
#> 4 4 14
#> 10 10 20
sample_by_column(data1,ID,7)
#> Warning: Work on function still in progress. Use with caution.
#> ID MOT
#> 2 2 12
#> 4 4 14
#> 5 5 15
#> 6 6 16
#> 7 7 17
#> 8 8 18
#> 10 10 20