2 years ago
#64419
Samin Ba
How use for loop for confidence interval in R?
I want to use a for loop to calculate a 95% confidence interval for the mean of humidity by month in R,
for(i in 1:12){
aa<-atmos_1995%>% group_by(month)%>% summarize(average=mean(temp))
bb<-atmos_1995%>% group_by(month)%>% summarize(sd=sd(temp))
lower_vector <-aa - 1.96 *bb/ sqrt(length(atmos_1995))
upper_vector <- aa + 1.96 * bb / sqrt(length(atmos_1995))
confi <- c(lower_vector[i], upper_vector[i])
print(confi)
}
how can I change the code to have intervals for the mean of each month?
r
for-loop
confidence-interval
0 Answers
Your Answer