getwd()
## [1] "E:/Coursera/ProjectCourse2"
library(plyr)
# Reading Data
NEI <- readRDS("summarySCC_PM25.rds")
# General Check NEI
dim(NEI)
## [1] 6497651 6
head(NEI)
## fips SCC Pollutant Emissions type year
## 4 09001 10100401 PM25-PRI 15.714 POINT 1999
## 8 09001 10100404 PM25-PRI 234.178 POINT 1999
## 12 09001 10100501 PM25-PRI 0.128 POINT 1999
## 16 09001 10200401 PM25-PRI 2.036 POINT 1999
## 20 09001 10200504 PM25-PRI 0.388 POINT 1999
## 24 09001 10200602 PM25-PRI 1.490 POINT 1999
sum(is.na(NEI))
## [1] 0
str(NEI)
## 'data.frame': 6497651 obs. of 6 variables:
## $ fips : chr "09001" "09001" "09001" "09001" ...
## $ SCC : chr "10100401" "10100404" "10100501" "10200401" ...
## $ Pollutant: chr "PM25-PRI" "PM25-PRI" "PM25-PRI" "PM25-PRI" ...
## $ Emissions: num 15.714 234.178 0.128 2.036 0.388 ...
## $ type : chr "POINT" "POINT" "POINT" "POINT" ...
## $ year : int 1999 1999 1999 1999 1999 1999 1999 1999 1999 1999 ...
# Question 01
# Have total emissions from PM2.5 decreased in the United States from 1999 to 2008?
total_EY <- aggregate(Emissions ~ year, NEI, sum)
dim(total_EY)
## [1] 4 2
print(total_EY)
## year Emissions
## 1 1999 7332967
## 2 2002 5635780
## 3 2005 5454703
## 4 2008 3464206
barplot((total_EY$Emissions)*10^(-6),
names.arg = total_EY$year,
xlab = "Year",
ylab = "Total PM2.5 Emission (10^6)",
main="Total PM2.5 Emissions From All United States",
border = "blue")

# Answer 01
# The chart show us that pollution in 2008 is less than in 1999, and so the answer is, yes.
# There is a decrease from 1999 to 2008. The air have less pollution PM2.5 in 2008.