title: writing a function to bootstrap CIs
body: <p>I'm trying to compute the bootstrapped CI for a statistic measure called CoRR but the function is running for up to 200 iterations and stops if I give it more than 200. </p>
  
  <pre><code>library(boot)
  
  corr&lt;-function(x,i){
  
    x2&lt;-x[i,]
  
  rr_c&lt;-epi.2by2((xtabs(~PRSH + depr, data=x2)[c(2,1), c(2,1)]))$res$RR.crude.wald[[1]]
  
  rr_a&lt;- epi.2by2((xtabs(~PRSH + depr + DHHGAGE, data=x2)[c(2,1), c(2,1),]))$res$RR.mh.wald[[1]]
  
  return(abs(log(rr_c/rr_a)))
  }
  
  boot.corr&lt;- boot(data=data, statistic=corr,R=1000)
  
  boot.ci(boot.corr, type="perc")
  </code></pre>
  
  <p>and this is how I have my variables coded:</p>
  
  <pre><code>data&lt;-subset(d, select=c(GEN_01, DHH_SEX, DEPDDPS, SDCFIMM, MHPFLSA, DHHGAGE))
  
  data$PRSH&lt;-ifelse(data$GEN_01 ==4 | data$GEN_01 ==5, 1, 0)
  
  data$sex &lt;- ifelse(data$DHH_SEX==2,1,0)
  
  data$depr&lt;-ifelse(data$DEPDDPS ==9, NA, ifelse(data$DEPDDPS ==1, 1, 0))
  </code></pre>
  
  <p>This is the error it produces: if (score > z) { : missing value where TRUE/FALSE needed</p>