title: bootstrap samples by row of a data frame in r
body: <p>I am trying to run a simple bootstrap on the rows of a data frame in r. Here is what I have worked up so far, but I'm hitting a dead end.</p>
  
  <pre><code>x1 &lt;- c(1:5)
  x2 &lt;- c(6:10)
  y &lt;- runif(5)
  z &lt;- as.data.frame(rbind(x1, x2, y))
  
  trial &lt;- 10
  avg &lt;- rep(0, trial)
  for(i in 1:trial){
    ind &lt;- sample(ncol(z), size = ncol(z), replace = TRUE)
    z.boot &lt;- z[ind, ]
    mean[i] &lt;- mean(z.boot)
  }
  mean
  </code></pre>
  
  <p>Ideally, what I would like to do is to get a bootstrap weighted mean for the first and second rows with the weights in the third row but I can't even get my loop to work. There has to be a better way to do this. Any help is appreciated</p>