R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

## Warning: package 'maps' was built under R version 4.1.1
## Warning: package 'ggmap' was built under R version 4.1.1
## Loading required package: ggplot2
## Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
## Please cite ggmap if you use it! See citation("ggmap") for details.
## Warning: package 'dplyr' was built under R version 4.1.1
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
## Warning: package 'maptools' was built under R version 4.1.1
## Loading required package: sp
## Warning: package 'sp' was built under R version 4.1.1
## Checking rgeos availability: FALSE
## Please note that 'maptools' will be retired by the end of 2023,
## plan transition at your earliest convenience;
## some functionality will be moved to 'sp'.
##      Note: when rgeos is not available, polygon geometry     computations in maptools depend on gpclib,
##      which has a restricted licence. It is disabled by default;
##      to enable gpclib, type gpclibPermit()
## Warning: package 'RCurl' was built under R version 4.1.1
## Warning: package 'plotly' was built under R version 4.1.1
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggmap':
## 
##     wind
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
## Warning: package 'scatterpie' was built under R version 4.1.1
## 
## Attaching package: 'scatterpie'
## The following object is masked from 'package:sp':
## 
##     recenter
## Warning: package 'mapproj' was built under R version 4.1.1

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

Including Plots

You can also embed plots, for example:

maxTempData = read.csv(url("https://www.ncdc.noaa.gov/cag/statewide/mapping/110-tmax-201906-60.csv"), skip=3)

maxTempData$region = tolower(maxTempData$Location)
us_states = map_data("state")
maxTempData = merge(us_states, maxTempData, by="region", all=T)

ggplot(maxTempData, aes(x = long, y = lat, group = group, fill = Value)) + 
geom_polygon(color = "white") +
scale_fill_gradient(name = "Degrees Fahrenheit", low = "#feceda", high = "#c81f49", guide = "colorbar", na.value="black") +
labs(title="Statewide Maximum Temperature [July 2014 - June 2019]", x="Longitude", y="Latitude")+
coord_map()

minTempData = read.csv(url("https://www.ncdc.noaa.gov/cag/statewide/mapping/110-tmin-201906-60.csv"),skip=3)

minTempData$region = tolower(minTempData$Location)
minTempData = merge(us_states, minTempData, by="region", all=T)

ggplot(minTempData, aes(x = long, y = lat, group = group, fill = Value)) + 
geom_polygon(color = "white") +
scale_fill_gradient(name = "Degrees Fahrenheit", na.value="black") +
labs(title="Statewide Minumum Temperature [July 2014 - June 2019] ", x="Longitude", y="Latitude")+
coord_map()

# The map shows the maximum temperature across each state for five years (2015-2019). For the past 5 five years, southern part of America is the region with the highest temp in the summer and highest temp in the winter. Northern region also has the lowest temp in the summer and lowest temp in the winter.**  

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

NHSI_data <- read.csv(url("https://www.ncdc.noaa.gov/snow-and-ice/extent/sea-ice/N/8.csv"),skip=3)

ggplot(NHSI_data,aes(x=Date,y=Value))+
  geom_point(color = "brown")+
  geom_smooth(method = 'lm', color = "tomato")+
  labs(title="August Northern Hemisphere Sea Ice Extent (1979-2019)",x="Year",y="million square km")
## `geom_smooth()` using formula 'y ~ x'

#From the above graph, the sea ice level is decreasing over years from 1975 to 2019 and this trend is very likely to continue due to global warm effect. 
HighTemp = read.csv(url("https://www.ncdc.noaa.gov/cag/national/time-series/110-tmax-7-7-1895-2020.csv?base_prd=true&begbaseyear=1985&endbaseyear=2020"), skip=4) 

HighTemp$Date = substr(HighTemp$Date, 0, 4) 
HighTemp$Date = as.numeric(HighTemp$Date) 

ggplot( HighTemp, aes( x = Date, y = Value)) + geom_line(color = 'Black') + geom_smooth(method='lm', se=FALSE, color='Red') + labs(title="Average maximum Temperatures in the month of July from 1985 to 2020", x="Year", y="Temperature (F)")
## `geom_smooth()` using formula 'y ~ x'

#The graph indicates the annual national Maximum temperature July month from 1895 to 2020 for the month of July and we can clearly see a historical trend. Average maximum temperture is increasing year over year through the whole period. 
HighTemp = read.csv(url("https://www.ncdc.noaa.gov/cag/national/time-series/110-tmin-1-1-1895-2020.csv?base_prd=true&begbaseyear=1985&endbaseyear=2020"), skip=4) 

HighTemp$Date = substr(HighTemp$Date, 0, 4) 
HighTemp$Date = as.numeric(HighTemp$Date) 

ggplot( HighTemp, aes( x = Date, y = Value)) + geom_line(color = 'Black') + geom_smooth(method='lm', se=FALSE, color='Red') + labs(title="Average minimum Temperatures in the month of January from 1985 to 2020", x="Year", y="Temperature (F)")
## `geom_smooth()` using formula 'y ~ x'

# Even in the coldest month of the year, the temperature is still increasing over years and it is a strong evidence of global warming effect and this trend is very likely to continue in the next a few decades if no powerful resolution is implemented.