resample_factor draws a random (sub)sample (with or without replacement) of the groups or clusters identified by the fac argument.

resample_factor(data, param = list(fac = "class", n = Inf, replace = FALSE))



a data.frame, rows represent samples


a list with the following components: fac is a factor variable of length nrow(data) or the name of a factor variable in data; n is a numeric value specifying the size of the subsample (in terms of groups, not observations); replace determines if resampling of groups is to be done with or without replacement.


a data.frame containing a subset of the rows of data.


If param$replace=FALSE, a subsample of min(param$n,nlevel(data[,fac])) groups will be drawn from data. If param$replace=TRUE, the number of groups to be drawn is param$n.

See also