-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmissions_materials.R
86 lines (75 loc) · 3.12 KB
/
Emissions_materials.R
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
###################################################################################
################## Exploration of USCG Emissions Data in Louisiana ################
################################### Joan Meiners 2018 #############################
############################ MATERIALS and PARTY RESPONSIBLE ######################
### This script is for combining all years of emissions data. See separate scripts for specific years ####
setwd("/Users/joanmeiners/Dropbox/NOLA.com/USCG-Emissions/")
#load libraries
library(dplyr)
library(tidyverse)
library(ggplot2)
# run other yearly scripts first to generate objects to combine
all_materials = full_join(CY04[ ,-53], CY05[ , -53])
all_materials = full_join(all_materials, CY06[ ,-53])
all_materials = full_join(all_materials, CY07[ ,-53])
all_materials = full_join(all_materials, CY08[ ,-53])
all_materials = full_join(all_materials, CY09[ ,-53])
all_materials = full_join(all_materials, CY10[ ,-53])
all_materials = full_join(all_materials, CY11[ ,-53])
all_materials = full_join(all_materials, CY12[ ,-53])
all_materials = full_join(all_materials, CY13[ ,-53])
all_materials = full_join(all_materials, CY14[ ,-53])
all_materials = full_join(all_materials, CY15[ ,-53])
all_materials = full_join(all_materials, CY16[ ,-53])
all_materials = full_join(all_materials, CY17[ ,-53])
all_materials = full_join(all_materials, CY18[ ,-53])
all_materials = full_join(all_materials, CY19[ ,-53])
dim(all_materials)
head(all_materials)
# separate combined dataset that only includes records of spills in Louisiana
unique(all_materials$LOCATION_STATE)
LA_materials = subset(all_materials, LOCATION_STATE == "LA")
dim(LA_materials)
names(LA_materials)
LA_MISS_materials = subset(LA_materials, BODY_OF_WATER == "MISSISSIPPI RIVER")
dim(LA_MISS_materials)
names(LA_MISS_materials)
LA_MISS_materials = LA_MISS_materials[ -c(69:119)]
LA_MISS_materials = LA_MISS_materials[ -c(27:65)]
LA_materials = LA_materials[ -c(69:119)]
LA_materials = LA_materials[ -c(27:65)]
# count spill incidences of certain materials
Materials = LA_MISS_materials %>%
group_by(NAME_OF_MATERIAL) %>%
summarise(
Spill_Count_by_material = n(),
Quantity = sum(AMOUNT_IN_WATER))
View(Materials)
write.csv(Materials, "Materials.csv", row.names = FALSE)
all_Materials = LA_materials %>%
group_by(NAME_OF_MATERIAL) %>%
summarise(
Spill_Count_by_material = n(),
Quantity = sum(AMOUNT_IN_WATER))
View(all_Materials)
# count spill incidences of certain responsible company
Companies = LA_MISS_materials %>%
filter(RESPONSIBLE_ORG_TYPE == "PRIVATE ENTERPRISE") %>%
group_by(RESPONSIBLE_COMPANY) %>%
summarise(
Spill_Count_by_company = n())
View(Companies)
write.csv(Companies, "Companies.csv", row.names = FALSE)
all_Companies = LA_materials %>%
filter(RESPONSIBLE_ORG_TYPE == "PRIVATE ENTERPRISE") %>%
group_by(RESPONSIBLE_COMPANY) %>%
summarise(
Spill_Count_by_company = n())
View(all_Companies)
# total spill quantities of certain responsible company
Org_Type = LA_MISS_materials %>%
group_by(RESPONSIBLE_ORG_TYPE) %>%
summarise(
Count_by_type = n())
View(Org_Type)
write.csv(Org_Type, "Org_type.csv", row.names = FALSE)