splitstackshape
splitstackshape copied to clipboard
sampling with replacement not working as expected
This code produces the warning "Groups F NY AA, F CA DD, M TX BB, M CA DD contain fewer rows than requested. Returning all rows." Each of the groups listed has 1 row in DF. With replace=TRUE I expect this row to be selected twice, but it is only selected one time.
set.seed(2) DF <- data.frame( ID = 1:100, A = sample(c("AA", "BB", "CC", "DD", "EE"), 100, replace = TRUE), B = rnorm(100), C = abs(round(rnorm(100), digits=1)), D = sample(c("CA", "NY", "TX"), 100, replace = TRUE), E = sample(c("M", "F"), 100, replace = TRUE))
stratified(DF, c("E", "D", "A"), size = 2, replace=TRUE)