0

I am new to using dates in R so sorry if this is a basic question. I have a data set that has the name of fracking wells and their job end date as listed below:

  df = as.data.frame(df)
    head(df)
`WellName                                JobEndDate
1                WILLIAM VALENTINE 1  5/19/1982 12:00:00 AM
2                LIZARD HEAD 1-8H RE   2/7/1995 12:00:00 AM
3 North Westbrook Unit/Well No. 3032  6/11/1996 12:00:00 AM
4                   Olene Reagan 3-1 12/13/2001 12:00:00 AM
5                               CNX3  9/22/2008 12:00:00 AM
7                              CNX2  1/22/2009 12:00:00 AM`

It is a large file with about 100,000 entries that go until 2017. I want to create a histogram based on the job end date. To do that, I figured I would place the dates into bins, breaking by months. However, I am struggling with placing them into bins so that each month has a number corresponding to how many wells were finished in each month. Therefore, I am also struggling with the histogram. I would appreciate any help!! Thank you!

Miha
  • 2,559
  • 2
  • 19
  • 34

1 Answers1

1

First, extract month from every date

library(data.table)
df$months <- month(df$JobEndDate)

Then, make your plot:

library(ggplot2)
ggplot(df, aes(x='months')) + geom_histogram()

# alternate
hist(table(df$months))
YOLO
  • 20,181
  • 5
  • 20
  • 40