1

I have a database with dates of florestal burn. I want make a histogram wiht this dates, would like verify such as month most fire burn.

my dates : 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

thelatemail
  • 91,185
  • 12
  • 128
  • 188
wesleysc352
  • 579
  • 1
  • 8
  • 21

1 Answers1

2

There's a hist.Date method.

hist(as.Date(d), breaks="months", xlab="Date", main="Forestal burn")

enter image description here


Example data:

d <- 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")
jay.sf
  • 60,139
  • 8
  • 53
  • 110
  • how did you manage to organize the data in "d"? I'm a newbie in R. – wesleysc352 Sep 03 '20 at 13:59
  • @wesleysc352 Try `(v <- unname(unlist(read.table(text="2010/09/21 2010/09/21 2010/09/21"))))`. How did my solution work for you? – jay.sf Sep 03 '20 at 14:23
  • sorry but i have a csv table with many dates, how would i do it automatically to generate "d" the same way you did? I am very lost in this matter. – wesleysc352 Sep 03 '20 at 15:26
  • @wesleysc352 Hey, you asked about how to make a histogram with dates, didn't you? If that worked you may accept the answer (_help_: [how-to accept-an-aswer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235)) and ask the topic in a new question, that's how it works here, you know ;) – jay.sf Sep 03 '20 at 15:42
  • yes it worked, but I can't generate this "d". Would I have to do it manually? – wesleysc352 Sep 03 '20 at 15:55
  • 1
    Nice answer. It might be cleaner to format the x-axis as month-year too - `hist(as.Date(d), breaks="months", las=2, format="%m-%y")` – thelatemail Sep 03 '20 at 23:58
  • @wesleysc352 - the `d` represents your date field in your dataset. Import your data like `dat <- read.csv("filename.csv")` then replace `d` with `dat$datevariablename` where `datevariablename` is the column containing your date information. – thelatemail Sep 03 '20 at 23:59
  • 1
    @thelatemail Thanks for the pointer, just noticed the `format` argument, really cool! For those interested in all the arguments: run `?hist.Date`. – jay.sf Sep 04 '20 at 05:45
  • i add freq=TRUE in code to calculate frequency---> hist(as.Date(d), breaks="months", xlab="Date", main="Forestal burn", freq=TRUE), thaks – wesleysc352 Sep 21 '20 at 02:50