Hi, I just joined the list, but here's a suggestion. x <- c(123, 48, 342, 442, 43, 232, 32, 129, 191, 147)
bins <- as.data.frame(table(cut(x, breaks=c(0, 100, 200, 300, 400, 500), labels=c("0-100", "100-200", "200-300", "300-400", "400-500")))) colnames(bins) <- c("bins", "count") > bins bins count 1 0-100 3 2 100-200 4 3 200-300 1 4 300-400 1 5 400-500 1 --Martin - ----- Original Message ----- From: Kathryn B Walters-Conte <kbw1...@yahoo.com> To: "r-help@r-project.org" <r-help@r-project.org> Cc: Sent: Monday, June 11, 2012 5:22 PM Subject: [R] Simple Binning of Values Hello I am very new to R. I have an R task to complete that I have not been able to find a straightforward answer to as of yet. I have a list of values. I would like to count the number of values that are in one bin, the number that fall in the next bin, etc. For example My input file is: 123 48 342 442 43 232 32 129 191 147 I would like the output to be similar to: 0-100 3 100-200 4 200-3001 300-400 1 400-5001 Thus far I have tried working with hist, cut and split, but have not gotten very far. Thanks Kat ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.