Update
Here's the best version of the code that can be more easily configured for any numeric number to separate:
dat <- data.frame(c1 = c("a", "a", "a", "b", "b", rep("c", 5)), c2=c(11, 14, 23, 12, 21, 17, 14, 29, 22, 25)) groups <- levels(dat$c1) nranges <- 2 limits <- c(10, 20, 30)
The result will be the same as shown below, with different colors and corresponding labels for the groups:

Original
This may not be ideal for your real data, but it works for your sample and gives you a start:
dat <- data.frame(c1 = c("a", "a", "a", "b", "b", rep("c", 5)), c2=c(11, 14, 23, 12, 21, 17, 14, 29, 22, 25)) groups <- levels(dat$c1) dat1 <- sapply(groups, function(i) sum(dat[dat$c2>10 & dat$c2<20,1]==i)) dat2 <- sapply(groups, function(i) sum(dat[dat$c2>20 & dat$c2<30,1]==i)) barplot(matrix(c(dat1, dat2), ncol=2), beside = TRUE, col=c("Red", "Green", "Blue"))
What generates:

The idea is to calculate the frequencies and then draw them using a barplot with complex data, rather than trying to use hist() .