using bootstrap to calculate t-test p-value and CI in r I have a data named best and i want to run bootstrap based on these hypothesis to get p-value and CI:
H0:mu<=1600 and H1:mu>1600
What I've tried is:
best <- c(1660, 1820, 1590,1440, 1730,1680,1750, 17201,900,1570,
             1700,1900,1800,1770,2010,1580,1620,1690)
ttest <- c(1:1000)
B      <- 1000
for(i in 1:B){
  boot.c <- sample(best, size=18, replace=T)
  ttest[i]  <- t.test(boot.c, mu = 1600)$statistic
}

p <-  (1 + sum(abs(ttest[i]) > abs(t.test(best,m=1600)$statistic))) / (1000+1)   
p

Is it right? is that so, how can i get CI?
In question we got ̅=1,718.3 And =137.8 to do the t-test without r but when i do it like:
 t.test(best, mu = 1600)

Obtained CI and p-value from code above are so different from what I've calculated with hand. why?
 A: You can run bootstrap using the boot package, and there are a few options for you to construct the confidence interval. First, the boot package can be used like this: 
library(boot)
bo = boot(best,function(dat,ind)mean(dat[ind]),R=999)

We can calculate confidence interval like this:
boot.ci(bo)

BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
Based on 999 bootstrap replicates

CALL : 
boot.ci(boot.out = bo)

Intervals : 
Level      Normal              Basic         
95%   ( 810, 4188 )   ( 718, 3478 )  

Level     Percentile            BCa          
95%   (1568, 4327 )   (1614, 6024 )  
Calculations and Intervals on Original Scale
Some BCa intervals may be unstable
Warning message:
In boot.ci(bo) : bootstrap variances needed for studentized intervals

And the mighty p-value like (btw @BruceET is correct):
(sum(bo$t>1600)+1)/(999+1)
[1] 0.941

Surprising result, 95% of our bootstrapped means are more than 1600? let's check how you bootstrapped mean looks like:
hist(bo$t,br=100,main="Histogram of bootstrapped means",xlab="mean")


This looks quite strange, and it is definitely so because you have n=18 and the 8th observation is 17201, ~10x more then the rest. We can look at this:
plot(boot.array(bo)[,8],bo$t,
xlab = "No of times column 8 is used",ylab="bootstrapped mean")


This may not be the answer you are looking for, but be careful when you have distributions like this. Bootstrap doesn't solve the problem but it does show you have shaky the estimation of the mean can be. The truth is you don't know if you try to measure these "best" values again, will you get an outlier like 17200, so I would say it doesn't make sense try to calculate p-values and 95% ci. 
A: There's not enough samples to perform the t approximation in the ttest, so by choosing bootstrap you can draw samples of your target statistics instead of approximate it with a t distribution.
Run boot.c = replicate(1000,mean(sample(best, size=18, replace=T))-1600) will get you the bootstrapped samples of your target statistics.
With the target statistics samples, you shouldn't do ttest on them, instead:
 P value:
sum(boot.c<0)/1000
95% confidence interval:
quantile(boot.c,c(0.025,0.975))
