#to suggest ranges for confidence intervals install.packages("data.table") library(data.table) #input list of confidence intervals Intervals = list( c(5,10), c(23,46), c(78,156), c(4.5,9), c(24,48), c(88,176), c(3.5,7), c(22.5,45), c(82,164), c(2.5,5) ) #put in data frame ints <- as.data.frame(do.call(rbind, Intervals)) #add names to columns names(ints) <- c('low', 'up') #loops compare with between and expand an interval when an overlap is found: for(x in 1:nrow(ints)){ for(y in 1:nrow(ints)){ if(between(ints$low[x], ints$low[y], ints$up[y],incbounds=TRUE)){ ints$low[x] <- ints$low[y] if(ints$up[y] > ints$up[x]){ ints$up[x] <- ints$up[y] } else { ints$up[y] <- ints$up[x] } } } } #get list of unique intervals, if some intervals are exactly the same ints <- unique(ints, margin = 1) #sort combined intervals ints <- ints[order(ints$low),] #display intervals ints