Date Histogram in GGPLOT

0

I'm not getting the ggplot from the following table:

 Data           Frequência
1 2016-06-11        3126
2 2016-03-05         218
3 2016-01-23         431
4 2016-06-04         145
5 2016-11-30         331
6 2016-15-01         275

Using the following code:

ggplot(data = data, aes(Frequência)) + geom_histogram()

Given the following warning stat_bin() using bins = 30. Pick better value with binwidth

The histogram format looks awkward too:

Sincerely, Arduin

    
asked by anonymous 26.12.2017 / 15:06

1 answer

0

If I understand correctly, you want to plot with a x-axis proportional to the calendar, correct?

Something like this here:

Remembertostorethedateinyourdata.frameasclassDate.Ifixedthemonth"15" in the example for "12".

data <- data.frame(Data=as.Date(c("2016-06-11", "2016-03-05", "2016-01-23", "2016-06-04", "2016-11-30", "2016-12-01"), format="%Y-%m-%d"),
                   Frequência=c(3126, 218, 431, 145, 331, 275))
ggplot(data = data,
       aes(x = Data,
           y = Frequência)) + geom_bar(stat = "identity")
    
02.01.2018 / 23:09