[R] Forcing hist()

Marc Schwartz (via MN) mschwartz at mn.rr.com
Wed Sep 14 20:32:27 CEST 2005

On Wed, 2005-09-14 at 20:17 +0200, Par Leijonhufvud wrote:
> I'm trying to create histogram (using hist()) that fullfill the following
> criteria:
>         * data is on a ordinal scale (1, 2, 3, 4, 5)
>         * I want bars centered over the number on the x-axis
>         * I want 5 bars of equal width
> I have tried various versions of the hist() command, with no luck. what
> am I missing?
> /Par

More than likely, you want to use barplot() and not hist():


  barplot(1:5, names.arg = 1:5)

See ?barplot for more information.


Marc Schwartz

P.S. To R Core: It probably makes sense to add barplot to the See Also
section of ?hist, since hist is listed in the See Also for ?barplot.

More information about the R-help mailing list