Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating bootstrap samples and storing sampled data in different names
    primarykey
    data
    text
    <p>When I create bootstrap samples from a data frame <code>datta</code> using the following codes</p> <pre><code>boot1a &lt;- replicate(3, do.call("rbind", lapply(sample(unique(datta$pid),2000,replace=TRUE), function(x) datta[datta$pid==x,])), simplify=FALSE) boot1b &lt;- data.frame(boot1a) # data frame from the list sample1 &lt;- boot1b[order(boot1b$pid),] # sorting based on pid and storing </code></pre> <p>variables in the bootstrap sample <code>sample1</code> have names ending with <code>.1, .2, .3, ...</code>. (<code>pid</code> is person ID, it takes similar values for different observations of the same person). For instance, with the above code a variable <code>xy</code> in <code>datta</code> will have names <code>xy</code>, <code>xy.1</code>, and <code>xy.2</code> associated with the first, the second and the third bootstrap samples. I would rather prefer to have different bootstrap samples named differently with the variable names in each remaining the same as those in the original data frame. In the above case, what I would like to have would be bootstrap samples stored in three different data frames, say, <code>boot1, boot2, boot3</code>, where variable names in each data frame is the same as that in the original data frame. I began doing it manually with one replication at a time, but it is gonna take a lot of time to create many bootstrap samples. Does somebody has any suggestion on how to do this in a better way?</p> <p><strong>EDIT</strong> The first few observations for four of the many variables in the data frame <code>datt</code> is as follows. </p> <pre><code> pid xy zy wy 1 10 2 -5 1 12 3 -4.5 1 14 4 -4 1 16 5 -3.5 1 18 6 -3 1 20 7 -2.5 2 22 8 -2 2 24 9 -1.5 2 26 10 -1 2 28 11 -0.5 2 30 12 0 2 32 13 0.5 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload