how to place histogram values at the top of the bar

I'm using the lattice library histogram command in R. I would like to know how I can put the value on top of the bars, value I speak of is the histogram count. Former: insert the description of the image here

Author: Thiago Oliveira, 2018-04-01

1 answers

As far as I know, more advanced graphical packages of R, such as lattice and ggplot2, do not have an easy way to place numbers on top of histogram bars. I imagine it will do, but it is quite a big job, precisely to discourage this use. This is due to the fact that almost no one currently thinks that histograms need to be accompanied by numbers. Graphics should be as clean as possible, so that they, and only they, manage to pass all the necessary information to the reader. Especially if the histogram has many categories, the look is extremely impaired if each column is accompanied by a number. If the use of numbers is unalterable, the suggestion is to use a table. It gets more elegant.

This being said, the hist function of R, having been written a long time ago, has an easy way to add numbers to histograms. Just add the argument labels=TRUE to your call:

hist(cars$speed, labels=TRUE)

insert the description of the image here

 5
Author: Marcus Nunes, 2018-04-01 19:26:04