Bob van den Berg
Bob van den Berg

Reputation: 244

Counting how many confidence intervals

So this is my table in R. For convienence I'll just do 5 replicates.

  V1         V2         V3         V4         V5
1 -1.4136084 -1.6883369 -0.9209277 -1.5650176 -1.4695545
2 0.2414484 -0.2508248 -0.1921887 0.1516668 0.3347349

How would I be able to count the times the value 0 is in between these other values? confidences[1] < 0 < confidences[2]

This is my code at the moment...

> x = 0
> confidences <- replicate(5,t.test(rnorm(n = 10, mean = -0.5, sd = 1))$conf)
> for(i in ncol(confidences)){if(confidences[1] < 0 & 0 < confidences[2]){x+1}}

Upvotes: 0

Views: 33

Answers (1)

G5W
G5W

Reputation: 37641

sum(confidences[1,]<0 & confidences[2,]>0)

Upvotes: 3

Related Questions