I would like to run a test for each species of ant that I have (columns 9-13) that compares values in the following columns: Attack_count, Attack_percent, Survival_count, and
Survival_percent. I want to make this comparison when individual ant species are ants>0 to when they are  ant==0.
This is what I have tried, and it returns pvalue=NA multiple times. This is my first attempt at writing a for loop and I do not know how to incorporate i. 
I added in the bootstrap code. I am not exactly sure how making a reproducible example goes but I wrote one in
bootstrap_ttest <- function(data1,data2,resamples){
    delta_real <- mean(data1) - mean(data2) ##real diff btwn means
    pooled_data <- c(data1, data2)
    null_differences <-c()
    for(x in 1:1000){
        data1_null <- sample(pooled_data,size=length(data1), replace=T)
        data2_null <- sample(pooled_data,size=length(data2), replace=T)
        delta_null <- mean(data1_null) - mean(data2_null)
        null_differences <- c(null_differences, delta_null )
    }## end of resampling loop 
    pvalue <- sum(abs(null_differences) > abs(delta_real))/length(null_differences)
    cat("pvalue:", pvalue)
    assign("pvalue", pvalue,.GlobalEnv) 
    assign("null_dist", null_differences,.GlobalEnv )
    assign("delta_obs", delta_real,.GlobalEnv )
}
ac_pvals = vector(length = ncol(ants))
ap_pvals = vector(length = ncol(ants))
sc_pvals = vector(length = ncol(ants))
sp_pvals = vector(length = ncol(ants))
for(i in 1:ncol(ants)){
  ants = data.frame(mainbroca[,9:13])
test1 = bootstrap_ttest(data1=mainbroca$Attack_count[ants == 0], 
                data2=mainbroca$Attack_count[ants>0], resamples=1000)
test2 = bootstrap_ttest(data1=mainbroca$Attack_percent[ants == 0], 
                data2=mainbroca$Attack_percent[ants>0], resamples=1000)
test3 = bootstrap_ttest(data1=mainbroca$Survival_count[ants == 0], 
                data2=mainbroca$Survival_count[ants>0], resamples=1000)
test4 = bootstrap_ttest(data1=mainbroca$Survival_percent[ants == 0], 
                data2=mainbroca$Survival_percent[ants>0], resamples=1000)
ac_pvals[1] = c(test1)
ap_pvals[1] = c(test2)
sc_pvals[1] = c(test3)
sp_pvals[1] = c(test4)
}
#reproducible
fakerow1 <- c(1,2,3,4,100,80,60,40,20)
fakerow2 <- c(1,2,3,4,100,80,60,40,20)
fakedata = rbind(fakerow1,fakerow2)
colnames(fakedata) = c('ac','ap','sc','sp','ant1','ant2','ant3','ant4','ant5')
 
     
     
    