Description Usage Arguments Value Examples
Using an original data frame with N subjects, creates data sets with all records from each of N subject IDs sampled with replacement. Final data sets are saved in a list.
1 | create.sampdata(org.data, id.var, n.sets, first.seed = 56)
|
org.data |
Original data set, of class |
id.var |
Character string; name of subject identifier variable to sample. |
n.sets |
Integer; number of final data sets desired. |
first.seed |
Numeric (defaults to 56); set for reproducibility. |
List of n.sets
data frames.
1 2 3 4 5 6 7 8 9 10 11 12 | df <- data.frame(id = sample(1:20, size = 100, replace = TRUE),
x1 = rnorm(n = 100),
x2 = rbinom(p = 0.75, n = 100, size = 1),
y = sample(LETTERS[1:3], size = 100, replace = TRUE))
df <- df[order(df$id),]
df$time <- unlist(lapply(1:length(unique(df$id)),
FUN = function(idnum){ 1:nrow(df[df$id == unique(df$id)[idnum],]) }))
## Using create.sampdata(), generate list of cluster bootstrapped data sets
bootdata.list <- create.sampdata(org.data = df,
id.var = 'id',
n.sets = 25)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.