I have a database with dates of florestal burn. I want make a histogram wiht this dates
I would like to generate a histogram with these dates and check which dates are more frequent
to start you
library(tidyverse)
set.seed(42)
(mydates <- tibble(d=sample(seq.Date(from=as.Date("2019/01/01"),
to=as.Date("2021/01/01")-1,
by=1),
size = 2000,
replace=TRUE
)))
(mydates_summarised <- group_by(mydates,
d) %>% summarise(count=n()) )
(maxcount <- max(mydates_summarised$count))
mydates_summarised <- mutate(mydates_summarised,
maxgroup = count==maxcount)
ggplot(data=mydates_summarised,
mapping=aes(x=d,y=count,fill=maxgroup)) + geom_col()
215/5000
I'm sorry but I was unable to execute the code, as numerous errors were generated.
I am a novice in R, you could help me to perform this task, I am sending a file with my data.
thank you very much
Date
2010-09-21
2010-09-21
2010-09-21
2010-09-21
2010-09-21
2010-09-21
2010-09-21
2010-10-18
2011-07-08
2011-07-08
2011-07-09
2011-07-09
2011-08-06
2011-08-13
2011-08-16
2011-08-16
2011-08-31
2011-08-31
2011-09-13
2011-09-13
2011-09-13
2011-09-13
2012-09-10
2012-09-08
2012-10-01
2012-11-22
2013-02-19
2013-03-05
2013-08-03
2013-08-14
2014-08-20
2013-09-13
2015-03-16
2015-03-14
2015-08-13
2020-04-11
2020-04-18
2020-04-18
2020-04-22
2020-04-22
2020-04-23
2020-04-23
2020-04-23
2020-04-27
2020-04-27
2020-04-27
2020-04-29
2020-04-29
2020-05-11
2020-04-28
2020-04-28
2020-06-12
2020-06-12
2020-06-12
2020-06-12
2020-08-11
2020-08-15
2020-08-15
2020-08-15
2020-08-29
2020-08-29
2020-08-29
2020-08-29
2015-10-19
2017-09-10
2018-03-23
2018-06-24
2018-09-11
2018-11-11
2018-11-11
2019-02-06
2019-02-22
2019-03-12
2019-04-14
2019-07-31
2019-07-31
2019-07-31
2016-11-06
2017-07-13
2017-07-13
2017-07-13
2017-07-24
2017-07-24
2017-08-30
2017-08-30
2017-08-30
2017-08-30
2017-03-25
Ideally, you should ask your questions with a REPRoducible EXample (reprex), since you are new here I'm going to make one for you this time.
Consider that a histogram implies binding of values so you have to choose a binwidth
suitable for your needs.
library(tidyverse)
library(lubridate)
sample_df <- data.frame(
Date = c("2010-09-21","2010-09-21","2010-09-21",
"2010-09-21","2010-09-21","2010-09-21","2010-09-21",
"2010-10-18","2011-07-08","2011-07-08","2011-07-09","2011-07-09",
"2011-08-06","2011-08-13","2011-08-16","2011-08-16",
"2011-08-31","2011-08-31","2011-09-13","2011-09-13","2011-09-13",
"2011-09-13","2012-09-10","2012-09-08","2012-10-01",
"2012-11-22","2013-02-19","2013-03-05","2013-08-03","2013-08-14",
"2014-08-20","2013-09-13","2015-03-16","2015-03-14",
"2015-08-13","2020-04-11","2020-04-18","2020-04-18","2020-04-22",
"2020-04-22","2020-04-23","2020-04-23","2020-04-23",
"2020-04-27","2020-04-27","2020-04-27","2020-04-29","2020-04-29",
"2020-05-11","2020-04-28","2020-04-28","2020-06-12",
"2020-06-12","2020-06-12","2020-06-12","2020-08-11","2020-08-15",
"2020-08-15","2020-08-15","2020-08-29","2020-08-29",
"2020-08-29","2020-08-29","2015-10-19","2017-09-10","2018-03-23",
"2018-06-24","2018-09-11","2018-11-11","2018-11-11",
"2019-02-06","2019-02-22","2019-03-12","2019-04-14","2019-07-31",
"2019-07-31","2019-07-31","2016-11-06","2017-07-13",
"2017-07-13","2017-07-13","2017-07-24","2017-07-24","2017-08-30",
"2017-08-30","2017-08-30","2017-08-30","2017-03-25")
)
sample_df %>%
mutate(Date = ymd(Date)) %>%
ggplot(aes(Date)) +
geom_histogram()
Created on 2020-09-04 by the reprex package (v0.3.0)
You will only get help with understanding and solving errors if you share what the errors are....
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.