title: Bootstrapping to compare two groups
body: <p>In the following code I use bootstrapping to calculate the C.I. and the p-value under the null hypothesis that two different fertilizers applied to tomato plants have no effect in plants yields (and the alternative being that the "improved" fertilizer is better). The first random sample (x) comes from plants where a standard fertilizer has been used, while an "improved" one has been used in the plants where the second sample (y) comes from.</p>
  
  <pre><code>x &lt;- c(11.4,25.3,29.9,16.5,21.1)
  y &lt;- c(23.7,26.6,28.5,14.2,17.9,24.3)
  total &lt;- c(x,y)
  library(boot)
  diff &lt;- function(x,i) mean(x[i[6:11]]) - mean(x[i[1:5]])
  b &lt;- boot(total, diff, R = 10000)
  
  ci &lt;- boot.ci(b)
  p.value &lt;- sum(b$t&gt;=b$t0)/b$R
  </code></pre>
  
  <p>What I don't like about the code above is that resampling is done as if there was only one sample of 11 values (separating the first 5 as belonging to sample x leaving the rest to sample y).
  Could you show me how this code should be modified in order to draw resamples of size 5 with replacement from the first sample and separate resamples of size 6 from the second sample, so that bootstrap resampling would mimic the “separate samples” design that produced the original data?</p>