[R] producing histogram-like plot

Philipp Pagel p.pagel at wzw.tum.de
Tue Mar 29 12:08:47 CEST 2011


On Tue, Mar 29, 2011 at 11:05:08AM +0200, Karin Lagesen wrote:
> Hi!
> 
> I have a dataset that looks like this:
> 
> 0.0	14
> 0.0	3
> 0.9	12
> ...and so on.
> 
> I would like to plot this in a histogram-like manner.

One way would be to re-create the original data and then simply use
hist:

dat <- data.frame(x=c(0,0,0.9,0.73,0.78,1,0.3,0.32), freq=c(14,3,12,15,2,15,2,8))
hist(with(dat, rep(x, times=freq)))

My example did not take special binning wishes into account but you
can easily customiye that with the breaks argument to hist.

cu
	Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
Maximus-von-Imhof-Forum 3
85354 Freising, Germany
http://webclu.bio.wzw.tum.de/~pagel/



More information about the R-help mailing list