[R] Histogram
Marc Schwartz
MSchwartz at mn.rr.com
Thu Sep 28 02:50:19 CEST 2006
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
More information about the R-help
mailing list