In the space below the rubric, provide a complete data citation so that anyone would be able to obtain the same dataset and produce similar results.
Preceptor Rubric
National Centers For Environmental Information, National Oceanic and Atmospheric Administration. Martinsburg Eastern West Virginia Regional Airport, 1950-01-01 to 2023-12-31. Downloaded 2024-09-03. https://www.ncdc.noaa.gov/cdo-web/datasets/GHCND/stations/GHCND:USC00465706/detail
In the R chunk below, require in the packages necessary and read in your unique weather data set.
Preceptor Rubric
require(lubridate)
require(tidyverse)
MTNSBG <- read.csv("martinsburg.csv",
stringsAsFactors = TRUE)
summary(MTNSBG)
## STATION
## USW00013734:27027
##
##
##
##
##
##
## NAME
## MARTINSBURG EASTERN WEST VIRGINIA REGIONAL AIRPORT, WV US:27027
##
##
##
##
##
##
## DATE PRCP TMAX TMIN
## 1950-01-01: 1 Min. :0.0000 Min. : 2.00 Min. :-18.00
## 1950-01-02: 1 1st Qu.:0.0000 1st Qu.: 49.00 1st Qu.: 30.00
## 1950-01-03: 1 Median :0.0000 Median : 67.00 Median : 43.00
## 1950-01-04: 1 Mean :0.1041 Mean : 64.69 Mean : 43.04
## 1950-01-05: 1 3rd Qu.:0.0400 3rd Qu.: 81.00 3rd Qu.: 58.00
## 1950-01-06: 1 Max. :3.7500 Max. :107.00 Max. : 82.00
## (Other) :27021 NA's :2 NA's :4
str(MTNSBG)
## 'data.frame': 27027 obs. of 6 variables:
## $ STATION: Factor w/ 1 level "USW00013734": 1 1 1 1 1 1 1 1 1 1 ...
## $ NAME : Factor w/ 1 level "MARTINSBURG EASTERN WEST VIRGINIA REGIONAL AIRPORT, WV US": 1 1 1 1 1 1 1 1 1 1 ...
## $ DATE : Factor w/ 27027 levels "1950-01-01","1950-01-02",..: 1 2 3 4 5 6 7 8 9 10 ...
## $ PRCP : num 0 0.18 0.09 0 0.02 0.08 0 0 0 0.04 ...
## $ TMAX : int 49 53 56 70 58 68 58 39 53 67 ...
## $ TMIN : int 29 38 40 53 51 50 31 23 17 41 ...
In the R chunk below, format your date column AND create new
columns that hold the values for month and year. Be sure run separate
summary() commands for each of these three columns to
demonstrate that your code works.
Preceptor Rubric
MTNSBG$DATE <- ymd(MTNSBG$DATE)
summary(MTNSBG$DATE)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## "1950-01-01" "1968-07-01" "1986-12-31" "1986-12-31" "2005-06-30" "2023-12-31"
str(MTNSBG$DATE)
## Date[1:27027], format: "1950-01-01" "1950-01-02" "1950-01-03" "1950-01-04" "1950-01-05" ...
MTNSBG$YEAR <- year(MTNSBG$DATE)
summary(MTNSBG$YEAR)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1950 1968 1986 1986 2005 2023
MTNSBG$MONTH <- month(MTNSBG$DATE)
summary(MTNSBG$MONTH)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.000 4.000 7.000 6.523 10.000 12.000
head(MTNSBG$MONTH)
## [1] 1 1 1 1 1 1
In the R-chunk below, extract a new data.frame of the twenty-year baseline based on what year your data starts. Check your year column with a summary to make certain the code worked.
Preceptor Rubric
range(MTNSBG$YEAR)
## [1] 1950 2023
MTNSBG_base <- MTNSBG %>%
filter(YEAR < 1971)
summary(MTNSBG_base)
## STATION
## USW00013734:7670
##
##
##
##
##
## NAME
## MARTINSBURG EASTERN WEST VIRGINIA REGIONAL AIRPORT, WV US:7670
##
##
##
##
##
## DATE PRCP TMAX TMIN
## Min. :1950-01-01 Min. :0.00000 Min. : 10.0 Min. :-13.00
## 1st Qu.:1955-04-02 1st Qu.:0.00000 1st Qu.: 48.0 1st Qu.: 29.00
## Median :1960-07-01 Median :0.00000 Median : 66.0 Median : 41.00
## Mean :1960-07-01 Mean :0.09458 Mean : 64.2 Mean : 41.48
## 3rd Qu.:1965-09-30 3rd Qu.:0.04000 3rd Qu.: 81.0 3rd Qu.: 56.00
## Max. :1970-12-31 Max. :3.64000 Max. :103.0 Max. : 77.00
## YEAR MONTH
## Min. :1950 Min. : 1.000
## 1st Qu.:1955 1st Qu.: 4.000
## Median :1960 Median : 7.000
## Mean :1960 Mean : 6.523
## 3rd Qu.:1965 3rd Qu.:10.000
## Max. :1970 Max. :12.000
In the R-chunk below, create a data.frame with monthly norms of maximum temperature for your baseline period. Graph the results as column ggplot to make certain the code works and the values are reasonable.
Preceptor Rubric
MTNSBG_norm <- MTNSBG_base %>%
group_by(MONTH) %>%
summarise(AVG_TMAX=
mean(TMAX, na.rm = T))
summary(MTNSBG_norm)
## MONTH AVG_TMAX
## Min. : 1.00 Min. :40.31
## 1st Qu.: 3.75 1st Qu.:48.97
## Median : 6.50 Median :65.88
## Mean : 6.50 Mean :64.10
## 3rd Qu.: 9.25 3rd Qu.:79.48
## Max. :12.00 Max. :86.87
ggplot(MTNSBG_norm,
aes(x=as.factor(MONTH),
y=AVG_TMAX))+
geom_col()+
labs(x="Month",
y="Average Max Temp (F)",
title="Monthly Temp. Averages")
In the R-chunk below, combine your temperature norms with your full weather dataset. Create new column that calculates the temperature anomaly, and plot the values as a histogram with ggplot to make certain the distribution is reasonable.
Preceptor Rubric
MTNSBG_full <- full_join(MTNSBG,MTNSBG_norm,
by ="MONTH")
summary(MTNSBG_full)
## STATION
## USW00013734:27027
##
##
##
##
##
##
## NAME
## MARTINSBURG EASTERN WEST VIRGINIA REGIONAL AIRPORT, WV US:27027
##
##
##
##
##
##
## DATE PRCP TMAX TMIN
## Min. :1950-01-01 Min. :0.0000 Min. : 2.00 Min. :-18.00
## 1st Qu.:1968-07-01 1st Qu.:0.0000 1st Qu.: 49.00 1st Qu.: 30.00
## Median :1986-12-31 Median :0.0000 Median : 67.00 Median : 43.00
## Mean :1986-12-31 Mean :0.1041 Mean : 64.69 Mean : 43.04
## 3rd Qu.:2005-06-30 3rd Qu.:0.0400 3rd Qu.: 81.00 3rd Qu.: 58.00
## Max. :2023-12-31 Max. :3.7500 Max. :107.00 Max. : 82.00
## NA's :2 NA's :4
## YEAR MONTH AVG_TMAX
## Min. :1950 Min. : 1.000 Min. :40.31
## 1st Qu.:1968 1st Qu.: 4.000 1st Qu.:51.10
## Median :1986 Median : 7.000 Median :67.34
## Mean :1986 Mean : 6.523 Mean :64.20
## 3rd Qu.:2005 3rd Qu.:10.000 3rd Qu.:82.95
## Max. :2023 Max. :12.000 Max. :86.87
##
MTNSBG_full$ANOMALY <- MTNSBG_full$TMAX - MTNSBG_full$AVG_TMAX
summary(MTNSBG_full$ANOMALY)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## -38.3057 -5.9492 0.1306 0.4833 6.6746 40.4199 4
ggplot(MTNSBG_full,
aes(x=ANOMALY))+
geom_histogram(bins=20)+
labs(x="Temperature Anomalies (F)",
y="Amount",
title="Monthly Temperature Anomalies")
In the R-chunk below, create a data.frame that shows the average yearly anomaly.
Preceptor Rubric
MTNSBG_yearly <- MTNSBG_full %>%
drop_na(ANOMALY) %>%
group_by(YEAR) %>%
summarise(AVG_ANOM=mean(ANOMALY, na.rm=T))
In the R-chunk below, create a fully-formatted ggplot using your yearly anomaly data.frame, with year on the x-axis, and temperature anomalies on the y-axis as columns with a “fill” color gradient that reinforces variation. Be sure to label all parts of your graph, and include the location of the weather data in the graph title.
Preceptor Rubric
ggplot(MTNSBG_yearly,
aes(x=YEAR,
y=AVG_ANOM,
fill=AVG_ANOM))+
geom_col()+
labs(x="Year",
y="Avg. Temp. Anomaly (F)",
title="Climate Trends in Martinsburg, WVA",
fill="Deg. F.")+
scale_fill_gradient(low="blue",
high="pink")+
ylim(-5,5.2)
In 3-4 sentences, describe in the space below the rubric what (if any) trends in climate you see in the figure you created for the previous question. Does your location follow global trends of increasing temperature? Are the extreme cold years of similar absolute magnitude to extreme warm years? In your life time, how many years have been cooler vs. warmer than the historic norm?
Instructor Rubric
The first thing I notice is the bright pink longer column right before the year 2000, which extends past 5 degrees, making this an unusually hot year out of the other results. Besides that, there seems to be a few spikes increasing towards the 2000s before decreasing up to today. Oddly enough, this does not match global temperature changes as it seems they’ve made progress in decreasing high temperature anomalies consistently. You can still see the impact of climate change due to the lack of cold anomalies in recent years (since the early 2000s). There seems to be an anomaly every few years regularly up until around the 80’s when anomalies started happening closer to each other. The cold yearly anomalies appear to be slightly less than the high ones, and have diminished in recent years. My experience was similar to others, I remember colder years when I was younger and haven’t experienced cold like that since, but the temperature is not as high as other places I’ve been in comparison.