Search code examples
rhistogramdata-analysis

Create histogram from summarized data R


How could I create a histogram from this set of summarized data in R?

enter image description here

I attempted this:

dataset <- c(4,17,12,6)
hist(dataset)

However, this showed me the data without the "0-19","60-99" breaks etc.

I would like to know how to create this histogram with the correct breaks and names. Thanks.


Solution

  • You need a barplot.

    Height = c(4,17,12,6)
    Bins = c("0-19", "20-39", "40-59", "60-99")
    barplot(Height, names.arg=Bins)
    

    Barplot

    barplot has many parameters that you might consider adjusting to make this prettier.