[R] Axes of a histogram

Marc Schwartz MSchwartz at mn.rr.com
Thu Sep 7 14:57:07 CEST 2006


On Thu, 2006-09-07 at 14:35 +0200, Rotkiv, Rehceb wrote:
> Hello everyone,
> 
> I would be glad if you could help out an R-beginner here... I have a
> vector of categorial data like this
> 
> > v <- c(1, 1, 2, 2, 2, 3, 3, 4, 4, 4)
> 
> When I do
> 
> > hist(v)
> 
> I get the x-axis of the histogram with floating point labels: 1.0, 1.5,
> 2.0, etc. Is it possible to tell R that the data consists of categories,
> i.e. that I only want the category names (1, 2, 3, 4) on my x-axis?
> 
> Thanks in advance,
> Rehceb Rotkiv

You don't want a histogram, but a barplot:

  barplot(table(v))

See ?barplot and ?table

HTH,

Marc Schwartz



More information about the R-help mailing list