sample <- rnorm(1000,mean=5,sd=10)
confint <- function(x,sample){
half_alpha <- qt(0.025,df=999)
conf_int <- mean(sample)+(sd(sample))/sqrt(1000)*c(half_alpha,-half_alpha)
if_include<- ifelse(conf_int[1]<x&conf_int[2]>x,TRUE,FALSE)
return(if_include)
}
library(tidyverse)
a <- map_lgl(sample,~confint(.x,sample))
sum(a)