Look at the cut, tapply, and barplot functions. There is probably also a nice way to do this using ggplot2 package.
-- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Karin Lagesen > Sent: Tuesday, March 29, 2011 3:05 AM > To: r-help@r-project.org > Subject: [R] producing histogram-like plot > > Hi! > > I have a dataset that looks like this: > > 0.0 14 > 0.0 3 > 0.9 12 > 0.73 15 > 0.78 2 > 1.0 15 > 0.3 2 > 0.32 8 > > ...and so on. > > I.e. a value between 0 and 1, and a number > > I would like to plot this in a histogram-like manner. I would like to > have a set of bins, each 0.1 wide, and plot the sum of values in column > 2 that falls within each bin. I.e, in this case I would like the first > bin, 0.0, to have the value 17, the second, 0.1, to have the value 0 > and > so on, until the last bin which has the value 15. I am sadly uncertain > of both how to sum these together, and also on which plot type to use. > > Thanks in advance! > > Karin > -- > Karin Lagesen, Ph.D. > Centre for Ecological and Evolutionary Synthesis (CEES) > University of Oslo, Dept. of Biology > P.O. Box 1066 Blindern 0316 Oslo, Norway > Ph. +47 22844132 Fax. +47 22854001 > Email karin.lage...@bio.uio.no > http://folk.uio.no/karinlag > > ______________________________________________ > 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. ______________________________________________ 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.