0

I try to add on my bar chart the frequencies of each bar of the chart but I can not find.

attach the code under R

Thank you

barplot(sort(CSP1,decreasing = T),ylim = c(0,0.35),
        xlab="Profession",
        ylab = "Frequence",
        main = "Diagramme montrant la fréquence des différentes profession en France",)

Clement
  • 5
  • 1
  • 1
    Clement, welcome to SO! Your question is somewhat common, so there are several good solutions available (two linked in the close message). In the future, please make your questions *reproducible*. In addition to the sample code you provided, this includes sample *unambiguous* data (e.g., `dput(head(x))` or `data.frame(x=...,y=...)`) and intended output given that input. Refs: https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info. Closing it as a dupe is nothing bad, it just encourages the existing answers to rise to the top. Thanks! – r2evans Nov 18 '20 at 19:01

1 Answers1

1

You can use the text() function to add the values above the bars.

Here's how with the VADeaths data used in the barplot helpfile:

data("VADeaths")
mp <- barplot(VADeaths)
tot <- colSums(VADeaths)
text(mp, tot + 3, format(tot), xpd = TRUE, col = "blue")

enter image description here

DanY
  • 5,920
  • 1
  • 13
  • 33