I am trying to sample a data frame from a given data frame such that there are enough samples from each of the levels of a variable. This can be achieved by separating the d
It would seem that if you want to sample a category that has less than 20 rows, you'd need replace=TRUE...
replace=TRUE
This might do the trick:
ddply(data1,'a',function(x) x[sample.int(NROW(x),20,replace=TRUE),])