1. test <- read.table(textConnection("age popperc
  2. 0-5 7
  3. 5-15 14
  4. 15-20 7
  5. 20-25 7
  6. 25-35 7
  7. 25-30 7
  8. 30-35 7
  9. 35-45 15
  10. 45-55 14
  11. 55-65 10
  12. 65-75 6
  13. 75-85 6"),header=TRUE,stringsAsFactors=FALSE)
  14.  
  15. midval <- sapply(strsplit(test$age,"-"),function(x) mean(as.numeric(x)))
  16. breakval <- strsplit(test$age,"-")
  17. breakval <- as.numeric(c(sapply(breakval,head,1),tail(unlist(breakval),1)))
  18. hist(rep(midval,test$popperc),breaks=breakval)