-
Notifications
You must be signed in to change notification settings - Fork 0
/
Wells_Over_Time.Rmd
61 lines (51 loc) · 1.34 KB
/
Wells_Over_Time.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
title: "Wells_Over_Time"
author: "Lourdes Vera"
date: "3/16/2021"
output: word_document
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
#Wells over Time
##Load Packages
```{r}
library(ggplot2)
library(stringr)
library(tidyverse)
```
##Load File
```{r}
df <- read_csv("All_Surface_Wells.csv")
```
##Clean Data Frame
```{r}
str(df)
```
```{r}
df2 <- df
#Extract year from completion data
df2$COMPLETIONYEAR <- as.numeric(stringr::str_extract(df2$COMPLETION, "^.{4}"))
df2
```
```{r}
#take out wells with completion date of 0
df2 <- df2[complete.cases(df2[c(21)]),]
df2 <- df2[-which(df2$COMPLETIONYEAR == 2021),]
df2$COMPLETIONYEAR[1:6]
```
```{r}
#group years by number of wells
df3<- df2 %>%
group_by(COMPLETIONYEAR) %>%
summarize(n=n())
#turn into numeric
df3$COMPLETIONYEAR <- as.numeric(df3$COMPLETIONYEAR)
df3$n <- as.numeric(df3$n)
```
##Histogram of Wells over Time
```{r}
ggplot(df3, aes(x=COMPLETIONYEAR, y=n)) + geom_point() + theme_classic() + scale_x_continuous(breaks = c(1935, 1940, 1945, 1950, 1955, 1960, 1965, 1970, 1975, 1980, 1985, 1990, 1995, 2000, 2005, 2010, 2015, 2020)) + ggtitle("Number of Completed Wells for Each Year, 1935-2020") + xlab("Year Well was Completed") + ylab("Number of Wells")
```