Re: [R] Histogram

From: Marc Schwartz <MSchwartz_at_mn.rr.com>
Date: Thu 28 Sep 2006 - 00:50:19 GMT

On Wed, 2006-09-27 at 18:29 -0400, Mohsen Jafarikia wrote:
> Dear all,
>
> I want to design a histogram and I need to have the frequency at certain
> points. For example I have the following 2 columns:
>
> *X Y*
>
> 0.1 25
> 0.4 22
> 0.45 11
> 0.55 21
>
> I want the chart to have 4 columns. First column is from 0.0-0.1 (on X) and
> frequency is 25. Next colum is wider and form 0.1-0.4 with 22 frequency.
> Next column is narrow with 11 frequency and the last column is the same as
> the first one with 21 frequency.
>
> Can anybody tell me how I can have this chart.
>
> Thanks,
> Mohsen

How about this:

X <- c(0, 0.1, 0.4, 0.45, 0.55)
Y <- c(25, 22, 11, 21)

barplot(Y, space = 0, width = diff(X))
axis(1)

See ?barplot and ?diff

HTH, Marc Schwartz



R-help@stat.math.ethz.ch 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. Received on Thu Sep 28 10:56:20 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 28 Sep 2006 - 02:30:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.