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.
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=longbroca$Attack_count[ants>0], resamples=1000)
test2 = bootstrap_ttest(data1=mainbroca$Attack_percent[ants == 0],
data2=longbroca$Attack_percent[ants>0], resamples=1000)
test3 = bootstrap_ttest(data1=mainbroca$Survival_count[ants == 0],
data2=longbroca$Survival_count[ants>0], resamples=1000)
test4 = bootstrap_ttest(data1=mainbroca$Survival_percent[ants == 0],
data2=longbroca$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)
}