finalpart1
Climate region effect on state economies
Author

Ethan Campbell

Published

October 15, 2022

Introduction

Extensive research has been done on climate change and economic changes respectively but there is not a significant amount of research about their relation towards one another. There are research papers that touch on this but in different aspects and focus more on other factors like political aspects. I would like to look a little broader and look at the difference between each climate zone and their economic differences. This can be taken with a grain of salt as there are many factors that could effect the economic situation being left out. The data was pulled from NASA’s POWER data access viewer; here I pulled the data by region since pulling the whole country in one go was unavailable. Thus, I will conduct research on each region respectively and then compare the results. This study will be conducted on the Köppen climate classification scale to determine climate types for study. I will keep the this one the first level of the scale as further scaling would take significantly more time to process.

Köppen climate classification

There are three levels to this climate classification the first scale is the 5 main climate groups A(tropical), B(Arid), C(Temperate), D(Continental), and E(Polar), the second layer is the seasonal precipitation type, and the final layer indicates the heat levels. Through this three layer system that was created by Wladimir Köppen in 1884 we are able to accurately dial in on a specific climate type. getwd() Climate Classification

Research Questions

A. Is there a relation between climate zone and economic growth?

B. Do Southern climates have the largest economic growth?

Hypothesis

My hypothesis is testing if there is an impact since certain climates effect the type of labor, conditions, longevity of materials, abundance of materials, and it alters the level of difficult of human growth. This study will focus more on generating climate regions and comparing the economic status within each region and try to identify trends that are occurring. I believe the regions with the biggest economic growth would be the south with their flatter lands or the west coast since its climate is good for technological advances.

The hypothesis will be tested as follows:

H0A

Climate region differences will not be predictors of economical change.

H1A

Climate region differences will be predictors of economical change.

H0A

Southern climates will not show greater economic growth.

H1A

Southern climates will show greater economic growth.

Analytical Planning

flowchart LR
  A[Importing Data] --> B(Data Cleaning)
  B --> C[Descriptive Statistics]
  C --> D(Hypothesis testing)
  D --> E[Regression Analysis 1]
  E --> F[Research Question 1]
  F --> G{Conclusion}
  D --> H[Regression Analysis 2]
  H --> I[Research Question 2]
  I --> G{Conclusion}

Library

Code
library(tidyverse)
Warning: package 'tidyverse' was built under R version 4.1.3
-- Attaching packages --------------------------------------- tidyverse 1.3.2 --
v ggplot2 3.3.6     v purrr   0.3.4
v tibble  3.1.8     v dplyr   1.0.9
v tidyr   1.2.0     v stringr 1.4.1
v readr   2.1.2     v forcats 0.5.2
Warning: package 'ggplot2' was built under R version 4.1.3
Warning: package 'tibble' was built under R version 4.1.3
Warning: package 'tidyr' was built under R version 4.1.3
Warning: package 'readr' was built under R version 4.1.3
Warning: package 'dplyr' was built under R version 4.1.3
Warning: package 'stringr' was built under R version 4.1.3
Warning: package 'forcats' was built under R version 4.1.3
-- Conflicts ------------------------------------------ tidyverse_conflicts() --
x dplyr::filter() masks stats::filter()
x dplyr::lag()    masks stats::lag()
Code
library(dplyr)
library(kableExtra)

Attaching package: 'kableExtra'

The following object is masked from 'package:dplyr':

    group_rows
Code
library(lubridate)

Attaching package: 'lubridate'

The following objects are masked from 'package:base':

    date, intersect, setdiff, union
Code
library(plyr)
Warning: package 'plyr' was built under R version 4.1.3
------------------------------------------------------------------------------
You have loaded plyr after dplyr - this is likely to cause problems.
If you need functions from both plyr and dplyr, please load plyr first, then dplyr:
library(plyr); library(dplyr)
------------------------------------------------------------------------------

Attaching package: 'plyr'

The following objects are masked from 'package:dplyr':

    arrange, count, desc, failwith, id, mutate, rename, summarise,
    summarize

The following object is masked from 'package:purrr':

    compact

Descriptive statistics

Reading in the data

Data was collected

Code
# Reading in all the weather data 

Amherst <- read.csv("_data/amherst.csv", skip = 14)
Florida <- read.csv("_data/flordia.csv", skip = 14)
Illinois <- read.csv("_data/illinois.csv", skip = 14)
Middle <- read.csv("_data/middle.csv", skip = 14)
Newmexico <- read.csv("_data/Newmexico.csv", skip = 14)
North <- read.csv("_data/North.csv", skip = 14)
South <- read.csv("_data/South.csv", skip = 14)
SouthCali <- read.csv("_data/SouthCali.csv", skip = 14)
Texas <- read.csv("_data/Texas.csv", skip = 14)
Washington <- read.csv("_data/washington.csv", skip = 14)
WestV <- read.csv("_data/WestV.csv", skip = 14)

Amherst

Had trouble with pivot_wider since it would split the values up by each name but then would fill in the values with NA for the other sections. This added a ton of NA values that one looked bad and were hard to deal with. I had to go a more manual way and do it for each part of PARAMETER to get the exact number of rows I needed. This stopped the NA values and got them all lined up so it reduced the size of the document from 500k+ rows to 89290 rows. This is huge in terms of running the data and working with it. Finally, I just merged the data together and then I was able to rename all the columns and start regression analysis.

Code
# Bringing all the month columns into one column
region <- Amherst %>%
pivot_longer(
  cols = c(NOV, JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, DEC),
  names_to = "MONTH",
  values_to = "Month_Average",
)

# trying to create a function that would apply to all regions
tidy_function <- function(region, Tidy_region, t2m, rh2m, wh10m, wh50m, PRECTOTCORR){
  Tidy_region <- region %>%
  select(PARAMETER, Month_Average, YEAR, LAT, LON, MONTH) %>%
  filter(PARAMETER == 'PS')
  Tidy_region <- Tidy_region %>%
  group_by(PARAMETER) %>%
  dplyr::mutate(row = row_number()) %>%
  tidyr::pivot_wider(names_from = PARAMETER, values_from = Month_Average) %>%
  select(-row)
  Tidy_region <- Tidy_region %>%
  select(PS, YEAR, MONTH, LAT, LON)
  t2m <- region %>%
  select(PARAMETER, Month_Average, YEAR) %>%
  filter(PARAMETER == 'T2M')
  t2m <- t2m %>%
  group_by(PARAMETER) %>%
  dplyr::mutate(row = row_number()) %>%
  tidyr::pivot_wider(names_from = PARAMETER, values_from = Month_Average) %>%
  select(-row)
  t2m <- t2m %>%
  select(T2M, YEAR)
  Tidy_region$T2M <- t2m$T2M
  rh2m <- region %>%
  select(PARAMETER, Month_Average, YEAR, LAT) %>%
  filter(PARAMETER == 'RH2M')
  rh2m <- rh2m %>%
  group_by(PARAMETER) %>%
  dplyr::mutate(row = row_number()) %>%
  tidyr::pivot_wider(names_from = PARAMETER, values_from = Month_Average) %>%
  select(-row)
  rh2m <- rh2m %>%
  select(RH2M, YEAR)
  Tidy_region$RH2M <- rh2m$RH2M
  wh10m <- region %>%
  select(PARAMETER, Month_Average, YEAR, LAT) %>%
  filter(PARAMETER == 'WS10M')
  wh10m <- wh10m %>%
  group_by(PARAMETER) %>%
  dplyr::mutate(row = row_number()) %>%
  tidyr::pivot_wider(names_from = PARAMETER, values_from = Month_Average) %>%
  select(-row)
  wh10m <- wh10m %>%
  select(WS10M, YEAR)
  Tidy_region$WS10M <- wh10m$WS10M
  wh50m <- region %>%
  select(PARAMETER, Month_Average, YEAR, LAT) %>%
  filter(PARAMETER == 'WS50M')
  wh50m <- wh50m %>%
  group_by(PARAMETER) %>%
  dplyr::mutate(row = row_number()) %>%
  tidyr::pivot_wider(names_from = PARAMETER, values_from = Month_Average) %>%
  select(-row)
  wh50m <- wh50m %>%
  select(WS50M, YEAR)
  Tidy_region$WS50M <- wh50m$WS50M
  PRECTOTCORR <- region %>%
  select(PARAMETER, Month_Average, YEAR, LAT) %>%
  filter(PARAMETER == 'PRECTOTCORR')
  PRECTOTCORR <- PRECTOTCORR %>%
  group_by(PARAMETER) %>%
  dplyr::mutate(row = row_number()) %>%
  tidyr::pivot_wider(names_from = PARAMETER, values_from = Month_Average) %>%
  select(-row)
  PRECTOTCORR <- PRECTOTCORR %>%
  select(PRECTOTCORR, YEAR)
  Tidy_region$PRECTOTCORR <- PRECTOTCORR$PRECTOTCORR
  # renaming all the variables to easier to digest names
  Tidy_region <- Tidy_region %>%
  dplyr::rename(Temperature = T2M) %>%
  dplyr::rename(Humidity = RH2M) %>%
  dplyr::rename(Wind_10_meter = WS10M) %>%
  dplyr::rename(Surface_Pressure = PS) %>%
  dplyr::rename(Wind_50_meter = WS50M) %>%
  dplyr::rename(Precipitation = PRECTOTCORR) %>%
  dplyr::rename(Latitude = LAT) %>%
  dplyr::rename(Longitude = LON) %>%
  dplyr::rename(Month = MONTH) %>%
  dplyr::rename(Year = YEAR)
}

Amherst <- tidy_function(region)

## Getting them in clean looking order
Amherst <- Amherst %>%
  select(Year, Month, Latitude, Longitude, Temperature, Humidity, Precipitation, Surface_Pressure, Wind_10_meter, Wind_50_meter)


Amherst <- Amherst %>%
  mutate(Temperature = Temperature* 9/5 + 32)

view_amherst <- Amherst %>%
  slice(1:10)

kable(view_amherst, digits = 2, align = "ccccccc", col.names = c("Year", "Month", "Latitude", "Longitude", "Temperature", "Humidity", "Precipitation", "Surface Pressure", "Wind 10 Meters", "Wind 50 Meters"), caption = "Amherst Data") %>%
  kable_styling(font_size = 16)
Amherst Data
Year Month Latitude Longitude Temperature Humidity Precipitation Surface Pressure Wind 10 Meters Wind 50 Meters
1990 NOV 35.25 -71.75 66.88 72.58 5.12 101.90 7.68 8.44
1990 JAN 35.25 -71.75 63.14 76.22 5.03 102.01 8.38 9.44
1990 FEB 35.25 -71.75 62.62 77.36 4.96 102.22 9.68 10.94
1990 MAR 35.25 -71.75 63.61 78.92 5.29 102.36 7.51 8.26
1990 APR 35.25 -71.75 65.52 75.35 3.96 101.87 7.51 8.26
1990 MAY 35.25 -71.75 69.93 76.08 3.31 101.63 7.21 8.15
1990 JUN 35.25 -71.75 74.68 82.84 4.56 101.67 6.56 7.42
1990 JUL 35.25 -71.75 78.75 83.94 4.89 101.81 6.32 7.19
1990 AUG 35.25 -71.75 79.18 79.47 3.31 101.76 4.12 4.57
1990 SEP 35.25 -71.75 76.84 74.81 2.72 101.67 5.11 5.57
Code
# aggregate the months into 1 year
# Converting abbreviation to normal word
Weather_region_Amherst$Month <- mapvalues(Weather_region_Amherst$Month, from = c("NOV", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "DEC"), to = c("November", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "December"))
Error in mapvalues(Weather_region_Amherst$Month, from = c("NOV", "JAN", : object 'Weather_region_Amherst' not found
Code
# Change word to numeric value
Weather_region_Amherst <- Weather_region_Amherst %>%
  mutate(Month = recode(Month,
                        January = 1,
                        February = 2,
                        March = 3,
                        April = 4,
                        May = 5,
                        June = 6,
                        July = 7,
                        August = 8,
                        September = 9,
                        October = 10,
                        November = 11,
                        December = 12))
Error in is.data.frame(.data): object 'Weather_region_Amherst' not found
Code
# Changing from year month to date column

Weather_region_Amherst$Date <- with(Weather_region_Amherst, ym(sprintf('%04d%02d', Year, Month)))
Error in with(Weather_region_Amherst, ym(sprintf("%04d%02d", Year, Month))): object 'Weather_region_Amherst' not found
Code
Year <- format(as.Date(Weather_region_Amherst$Date), format = "%Y")
Error in as.Date(Weather_region_Amherst$Date): object 'Weather_region_Amherst' not found
Code
Weather_region_Amherst %>%
  group_by(Latitude, Longitude) %>%
  mutate(Annual_Temperature = mean(Temperature),
      Annual_Humidity = mean(Humidity),
      Annual_Precipitation = sum(Precipitation))
Error in group_by(., Latitude, Longitude): object 'Weather_region_Amherst' not found
Code
# creating the mean value for each long and lat for each variable
Means_variables <- ddply(Weather_region_Amherst, .(Year, Latitude, Longitude), summarise,
      Annual_Temperature = mean(Temperature),
      Annual_Humidity = mean(Humidity),
      Annual_Precipitation = sum(Precipitation),
      Average_Pressure = mean(Surface_Pressure),
      Average_Wind_10Meter = mean(Wind_10_meter),
      Average_Wind_50Meter = mean(Wind_50_meter))
Error in empty(.data): object 'Weather_region_Amherst' not found
Code
# Creating the regions based on longitude and latitude 
Weather_region_Amherst <- Means_variables %>%
  mutate(Regions = case_when(
    Latitude >= 23.25 & Latitude <= 40.75 & Longitude >= -95.5 & Longitude <= -70.5 ~ 'Southeast',
    Latitude >= 25 & Latitude <= 37 & Longitude >= -114.75 & Longitude <= -95.6 ~ 'Southwest',
    Latitude >= 32.3 & Latitude <= 49 & Longitude >= -124.36 & Longitude <= -102 ~ 'West',
    Latitude >= 39.7 & Latitude <= 47.4 & Longitude >= -81 & Longitude <= -66 ~ 'Northeast',
    Latitude >= 35 & Latitude <= 49 & Longitude >= -104 & Longitude <= -80.5 ~ 'Midwest'
  ))
Error in is.data.frame(.data): object 'Means_variables' not found
Code
data <- merge(Means_variables, Economy)
Error in merge(Means_variables, Economy): object 'Means_variables' not found
Code
data <- data %>%
  distinct(Annual_Temperature, Annual_Humidity, Annual_Precipitation, Year_Money_Millions)
Error in UseMethod("distinct"): no applicable method for 'distinct' applied to an object of class "function"
Code
cor(data$Year_Money_Millions ~ data$Annual_Temperature)
Error in cor(data$Year_Money_Millions ~ data$Annual_Temperature): supply both 'x' and 'y' or a matrix-like 'x'
Code
test <- lm(Year_Money_Millions ~ log(Annual_Temperature), data = data)
Error in model.frame.default(formula = Year_Money_Millions ~ log(Annual_Temperature), : 'data' must be a data.frame, environment, or list
Code
summary(test)
Error in summary(test): object 'test' not found
Code
plot(test)
Error in plot(test): object 'test' not found
Code
corrplot(data)
Error in corrplot(data): could not find function "corrplot"
Code
plot(Year_Money_Millions ~ Annual_Temperature + Annual_Humidity + Annual_Precipitation, 
     data = data, 
     col = "steelblue", 
     pch = 20, 
     xlim = c(0, 100),
     cex.main = 0.9,
     main = "Percentage of English language learners")
Error in FUN(X[[i]], ...): invalid 'envir' argument of type 'closure'
Code
# Creating weather types

# Creating the 4 regions 

Florida

Code
region <- Florida %>%
pivot_longer(
  cols = c(NOV, JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, DEC),
  names_to = "MONTH",
  values_to = "Month_Average",
)


Florida <- tidy_function(region)
Florida <- Florida %>%
  select(Year, Month, Latitude, Longitude, Temperature, Humidity, Precipitation, Surface_Pressure, Wind_10_meter, Wind_50_meter)

summary(Florida)
      Year         Month              Latitude       Longitude     
 Min.   :1990   Length:88536       Min.   :25.25   Min.   :-85.75  
 1st Qu.:1997   Class :character   1st Qu.:26.75   1st Qu.:-83.75  
 Median :2005   Mode  :character   Median :28.50   Median :-81.75  
 Mean   :2005                      Mean   :28.50   Mean   :-81.75  
 3rd Qu.:2013                      3rd Qu.:30.25   3rd Qu.:-79.75  
 Max.   :2020                      Max.   :31.75   Max.   :-77.75  
  Temperature       Humidity     Precipitation    Surface_Pressure
 Min.   : 3.76   Min.   :51.16   Min.   : 0.030   Min.   : 99.85  
 1st Qu.:20.46   1st Qu.:74.69   1st Qu.: 1.760   1st Qu.:101.45  
 Median :23.99   Median :77.32   Median : 3.050   Median :101.64  
 Mean   :23.20   Mean   :77.26   Mean   : 3.529   Mean   :101.61  
 3rd Qu.:27.24   3rd Qu.:80.12   3rd Qu.: 4.760   3rd Qu.:101.82  
 Max.   :30.83   Max.   :91.78   Max.   :22.510   Max.   :102.48  
 Wind_10_meter  Wind_50_meter   
 Min.   :1.24   Min.   : 2.520  
 1st Qu.:3.51   1st Qu.: 4.660  
 Median :4.69   Median : 5.660  
 Mean   :4.74   Mean   : 5.719  
 3rd Qu.:5.95   3rd Qu.: 6.690  
 Max.   :9.74   Max.   :10.840  
Code
view_Florida <- Florida %>%
  slice(1:10)

kable(view_Florida, digits = 2, align = "ccccccc", col.names = c("Year", "Month", "Latitude", "Longitude", "Temperature", "Humidity", "Precipitation", "Surface Pressure", "Wind 10 Meters", "Wind 50 Meters"), caption = "Florida Data") %>%
  kable_styling(font_size = 16)
Florida Data
Year Month Latitude Longitude Temperature Humidity Precipitation Surface Pressure Wind 10 Meters Wind 50 Meters
1990 NOV 25.25 -77.75 24.69 74.40 1.29 101.74 6.76 7.59
1990 JAN 25.25 -77.75 24.01 76.50 0.49 101.99 5.74 6.45
1990 FEB 25.25 -77.75 23.83 73.11 0.72 102.09 7.30 8.20
1990 MAR 25.25 -77.75 23.44 75.67 1.04 102.02 7.12 7.99
1990 APR 25.25 -77.75 24.18 72.43 0.82 101.72 5.53 6.10
1990 MAY 25.25 -77.75 25.89 78.25 2.60 101.65 5.60 6.24
1990 JUN 25.25 -77.75 27.27 77.06 2.91 101.74 4.18 4.62
1990 JUL 25.25 -77.75 28.25 76.18 2.41 101.74 4.47 4.93
1990 AUG 25.25 -77.75 28.77 74.23 5.13 101.71 3.16 3.44
1990 SEP 25.25 -77.75 28.55 74.47 2.09 101.51 3.85 4.16
Code
Weather_region_Florida <- Florida %>%
  mutate(Regions = case_when(
    Latitude >= 23.25 & Latitude <= 40.75 & Longitude >= -95.5 & Longitude <= -70.5 ~ 'Southeast',
    Latitude >= 25 & Latitude <= 37 & Longitude >= -114.75 & Longitude <= -95.6 ~ 'Southwest',
    Latitude >= 32.3 & Latitude <= 49 & Longitude >= -124.36 & Longitude <= -102 ~ 'West',
    Latitude >= 39.7 & Latitude <= 47.4 & Longitude >= -81 & Longitude <= -66 ~ 'Northeast',
    Latitude >= 35 & Latitude <= 49 & Longitude >= -104 & Longitude <= -80.5 ~ 'Midwest'
  ))

Weather_region_Florida

Illinois

Code
region <- Illinois %>%
pivot_longer(
  cols = c(NOV, JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, DEC),
  names_to = "MONTH",
  values_to = "Month_Average",
)


Illinois <- tidy_function(region)

Illinois <- Illinois %>%
  select(Year, Month, Latitude, Longitude, Temperature, Humidity, Precipitation, Surface_Pressure, Wind_10_meter, Wind_50_meter)

summary(Illinois)
      Year         Month              Latitude       Longitude      
 Min.   :1990   Length:66960       Min.   :43.25   Min.   :-102.75  
 1st Qu.:1997   Class :character   1st Qu.:44.25   1st Qu.:-100.75  
 Median :2005   Mode  :character   Median :45.50   Median : -98.50  
 Mean   :2005                      Mean   :45.50   Mean   : -98.50  
 3rd Qu.:2013                      3rd Qu.:46.75   3rd Qu.: -96.25  
 Max.   :2020                      Max.   :47.75   Max.   : -94.25  
  Temperature         Humidity     Precipitation    Surface_Pressure
 Min.   :-22.850   Min.   :31.92   Min.   : 0.010   Min.   :89.54   
 1st Qu.: -2.780   1st Qu.:61.57   1st Qu.: 0.570   1st Qu.:94.45   
 Median :  7.450   Median :68.34   Median : 1.220   Median :95.83   
 Mean   :  7.186   Mean   :69.63   Mean   : 1.615   Mean   :95.46   
 3rd Qu.: 18.120   3rd Qu.:77.34   3rd Qu.: 2.340   3rd Qu.:96.79   
 Max.   : 30.490   Max.   :97.99   Max.   :10.000   Max.   :99.02   
 Wind_10_meter   Wind_50_meter   
 Min.   :3.130   Min.   : 4.740  
 1st Qu.:4.690   1st Qu.: 6.660  
 Median :5.130   Median : 7.180  
 Mean   :5.104   Mean   : 7.155  
 3rd Qu.:5.520   3rd Qu.: 7.650  
 Max.   :7.600   Max.   :10.240  
Code
view_Illinois <- Illinois %>%
  slice(1:10)

kable(view_Illinois, digits = 2, align = "ccccccc", col.names = c("Year", "Month", "Latitude", "Longitude", "Temperature", "Humidity", "Precipitation", "Surface Pressure", "Wind 10 Meters", "Wind 50 Meters"), caption = "Illinois Data") %>%
  kable_styling(font_size = 16)
Illinois Data
Year Month Latitude Longitude Temperature Humidity Precipitation Surface Pressure Wind 10 Meters Wind 50 Meters
1990 NOV 43.25 -100.25 4.22 58.51 0.38 93.25 5.64 8.36
1990 JAN 43.25 -100.25 -0.49 64.46 0.05 93.03 6.12 8.84
1990 FEB 43.25 -100.25 -1.83 59.56 0.35 93.50 5.79 7.96
1990 MAR 43.25 -100.25 2.89 63.46 1.46 93.49 5.29 7.35
1990 APR 43.25 -100.25 8.98 52.07 1.52 93.29 5.24 7.18
1990 MAY 43.25 -100.25 13.64 62.47 4.21 93.15 5.01 6.97
1990 JUN 43.25 -100.25 22.23 54.08 2.60 93.06 5.26 7.45
1990 JUL 43.25 -100.25 23.62 53.65 2.88 93.46 4.07 5.88
1990 AUG 43.25 -100.25 24.19 55.66 1.93 93.42 3.73 5.50
1990 SEP 43.25 -100.25 20.72 43.86 0.50 93.55 4.70 6.89
Code
Weather_region_Illinois <- Illinois %>%
  mutate(Regions = case_when(
    Latitude >= 23.25 & Latitude <= 40.75 & Longitude >= -95.5 & Longitude <= -70.5 ~ 'Southeast',
    Latitude >= 25 & Latitude <= 37 & Longitude >= -114.75 & Longitude <= -95.6 ~ 'Southwest',
    Latitude >= 32.3 & Latitude <= 49 & Longitude >= -124.36 & Longitude <= -102 ~ 'West',
    Latitude >= 39.7 & Latitude <= 47.4 & Longitude >= -81 & Longitude <= -66 ~ 'Northeast',
    Latitude >= 35 & Latitude <= 49 & Longitude >= -104 & Longitude <= -80.5 ~ 'Midwest'
  ))

Weather_region_Illinois

Middle

Code
region <- Middle %>%
pivot_longer(
  cols = c(NOV, JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, DEC),
  names_to = "MONTH",
  values_to = "Month_Average",
)

Middle <- tidy_function(region)

Middle <- Middle %>%
  select(Year, Month, Latitude, Longitude, Temperature, Humidity, Precipitation, Surface_Pressure, Wind_10_meter, Wind_50_meter)

summary(Middle)
      Year         Month              Latitude       Longitude      
 Min.   :1990   Length:77748       Min.   :38.25   Min.   :-102.75  
 1st Qu.:1997   Class :character   1st Qu.:39.25   1st Qu.:-100.75  
 Median :2005   Mode  :character   Median :40.75   Median : -98.25  
 Mean   :2005                      Mean   :40.75   Mean   : -98.25  
 3rd Qu.:2013                      3rd Qu.:42.25   3rd Qu.: -95.75  
 Max.   :2020                      Max.   :43.25   Max.   : -93.75  
  Temperature        Humidity     Precipitation    Surface_Pressure
 Min.   :-14.92   Min.   :32.96   Min.   : 0.000   Min.   :85.57   
 1st Qu.:  1.38   1st Qu.:58.52   1st Qu.: 0.690   1st Qu.:91.58   
 Median : 10.92   Median :66.34   Median : 1.540   Median :95.39   
 Mean   : 10.92   Mean   :66.23   Mean   : 1.949   Mean   :94.30   
 3rd Qu.: 20.83   3rd Qu.:74.14   3rd Qu.: 2.840   3rd Qu.:97.13   
 Max.   : 32.89   Max.   :96.56   Max.   :15.870   Max.   :99.52   
 Wind_10_meter   Wind_50_meter   
 Min.   :2.440   Min.   : 3.890  
 1st Qu.:4.530   1st Qu.: 6.550  
 Median :5.030   Median : 7.160  
 Mean   :4.994   Mean   : 7.111  
 3rd Qu.:5.480   3rd Qu.: 7.710  
 Max.   :7.450   Max.   :10.050  
Code
view_Middle <- Middle %>%
  slice(1:10)

kable(view_Middle, digits = 2, align = "ccccccc", col.names = c("Year", "Month", "Latitude", "Longitude", "Temperature", "Humidity", "Precipitation", "Surface Pressure", "Wind 10 Meters", "Wind 50 Meters"), caption = "Middle Data") %>%
  kable_styling(font_size = 16)
Middle Data
Year Month Latitude Longitude Temperature Humidity Precipitation Surface Pressure Wind 10 Meters Wind 50 Meters
1990 NOV 38.25 -100.25 8.05 51.61 0.62 92.47 5.22 7.63
1990 JAN 38.25 -100.25 1.32 60.67 0.99 92.31 5.20 7.99
1990 FEB 38.25 -100.25 2.00 56.02 1.05 92.53 5.04 7.06
1990 MAR 38.25 -100.25 7.51 59.24 1.22 92.45 5.05 7.07
1990 APR 38.25 -100.25 12.46 55.89 2.66 92.34 5.83 7.93
1990 MAY 38.25 -100.25 16.73 59.86 3.97 92.05 5.70 7.80
1990 JUN 38.25 -100.25 26.79 47.33 1.43 92.11 6.06 8.42
1990 JUL 38.25 -100.25 26.56 50.47 3.16 92.47 5.35 7.31
1990 AUG 38.25 -100.25 26.06 52.42 1.77 92.52 4.82 6.97
1990 SEP 38.25 -100.25 22.98 47.95 1.43 92.63 4.49 6.54
Code
Weather_region_Middle <- Middle %>%
  mutate(Regions = case_when(
    Latitude >= 23.25 & Latitude <= 40.75 & Longitude >= -95.5 & Longitude <= -70.5 ~ 'Southeast',
    Latitude >= 25 & Latitude <= 37 & Longitude >= -114.75 & Longitude <= -95.6 ~ 'Southwest',
    Latitude >= 32.3 & Latitude <= 49 & Longitude >= -124.36 & Longitude <= -102 ~ 'West',
    Latitude >= 39.7 & Latitude <= 47.4 & Longitude >= -81 & Longitude <= -66 ~ 'Northeast',
    Latitude >= 35 & Latitude <= 49 & Longitude >= -104 & Longitude <= -80.5 ~ 'Midwest'
  ))

Weather_region_Middle

New Mexico

Code
region <- Newmexico %>%
pivot_longer(
  cols = c(NOV, JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, DEC),
  names_to = "MONTH",
  values_to = "Month_Average",
)

New_Mexico <- tidy_function(region)

New_Mexico <- New_Mexico %>%
  select(Year, Month, Latitude, Longitude, Temperature, Humidity, Precipitation, Surface_Pressure, Wind_10_meter, Wind_50_meter)

summary(New_Mexico)
      Year         Month              Latitude       Longitude     
 Min.   :1990   Length:81840       Min.   :32.75   Min.   :-112.8  
 1st Qu.:1997   Class :character   1st Qu.:33.75   1st Qu.:-110.4  
 Median :2005   Mode  :character   Median :35.25   Median :-108.0  
 Mean   :2005                      Mean   :35.25   Mean   :-108.0  
 3rd Qu.:2013                      3rd Qu.:36.75   3rd Qu.:-105.6  
 Max.   :2020                      Max.   :37.75   Max.   :-103.2  
  Temperature        Humidity     Precipitation    Surface_Pressure
 Min.   :-14.10   Min.   :11.31   Min.   :0.0000   Min.   :69.19   
 1st Qu.:  4.54   1st Qu.:38.12   1st Qu.:0.3000   1st Qu.:79.63   
 Median : 12.08   Median :46.83   Median :0.7200   Median :82.13   
 Mean   : 12.43   Mean   :46.47   Mean   :0.9725   Mean   :82.40   
 3rd Qu.: 20.55   3rd Qu.:54.76   3rd Qu.:1.3900   3rd Qu.:84.65   
 Max.   : 36.19   Max.   :95.05   Max.   :8.0500   Max.   :97.50   
 Wind_10_meter   Wind_50_meter   
 Min.   :1.630   Min.   : 2.530  
 1st Qu.:3.240   1st Qu.: 4.750  
 Median :3.770   Median : 5.510  
 Mean   :3.879   Mean   : 5.638  
 3rd Qu.:4.460   3rd Qu.: 6.460  
 Max.   :7.730   Max.   :10.510  
Code
view_Newmexico <- New_Mexico %>%
  slice(1:10)

kable(view_Newmexico, digits = 2, align = "ccccccc", col.names = c("Year", "Month", "Latitude", "Longitude", "Temperature", "Humidity", "Precipitation", "Surface Pressure", "Wind 10 Meters", "Wind 50 Meters"), caption = "Amherst Data") %>%
  kable_styling(font_size = 16)
Amherst Data
Year Month Latitude Longitude Temperature Humidity Precipitation Surface Pressure Wind 10 Meters Wind 50 Meters
1990 NOV 32.75 -103.25 10.38 53.91 0.81 89.29 4.55 6.89
1990 JAN 32.75 -103.25 5.43 44.72 0.42 89.19 5.05 7.59
1990 FEB 32.75 -103.25 8.46 41.76 0.68 89.11 5.54 7.98
1990 MAR 32.75 -103.25 11.39 47.90 0.83 89.07 4.88 6.90
1990 APR 32.75 -103.25 17.02 45.33 0.92 88.92 5.27 7.37
1990 MAY 32.75 -103.25 21.71 32.06 0.35 88.77 5.65 7.89
1990 JUN 32.75 -103.25 30.18 28.31 0.07 88.93 5.54 7.52
1990 JUL 32.75 -103.25 25.56 52.40 2.68 89.26 4.55 6.00
1990 AUG 32.75 -103.25 25.00 53.48 1.68 89.34 3.80 5.52
1990 SEP 32.75 -103.25 22.76 57.93 2.12 89.33 3.37 4.93
Code
Weather_region_Newmexico <- New_Mexico %>%
  mutate(Regions = case_when(
    Latitude >= 23.25 & Latitude <= 40.75 & Longitude >= -95.5 & Longitude <= -70.5 ~ 'Southeast',
    Latitude >= 25 & Latitude <= 37 & Longitude >= -114.75 & Longitude <= -95.6 ~ 'Southwest',
    Latitude >= 32.3 & Latitude <= 49 & Longitude >= -124.36 & Longitude <= -102 ~ 'West',
    Latitude >= 39.7 & Latitude <= 47.4 & Longitude >= -81 & Longitude <= -66 ~ 'Northeast',
    Latitude >= 35 & Latitude <= 49 & Longitude >= -104 & Longitude <= -80.5 ~ 'Midwest'
  ))

Weather_region_Newmexico

North

Code
region <- North %>%
pivot_longer(
  cols = c(NOV, JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, DEC),
  names_to = "MONTH",
  values_to = "Month_Average",
)
North <- tidy_function(region)

North <- North %>%
  select(Year, Month, Latitude, Longitude, Temperature, Humidity, Precipitation, Surface_Pressure, Wind_10_meter, Wind_50_meter)

summary(North)
      Year         Month              Latitude       Longitude     
 Min.   :1990   Length:74400       Min.   :43.25   Min.   :-113.2  
 1st Qu.:1997   Class :character   1st Qu.:44.25   1st Qu.:-110.9  
 Median :2005   Mode  :character   Median :45.50   Median :-108.5  
 Mean   :2005                      Mean   :45.50   Mean   :-108.5  
 3rd Qu.:2013                      3rd Qu.:46.75   3rd Qu.:-106.1  
 Max.   :2020                      Max.   :47.75   Max.   :-103.8  
  Temperature         Humidity     Precipitation   Surface_Pressure
 Min.   :-18.250   Min.   :21.78   Min.   :0.010   Min.   :72.47   
 1st Qu.: -2.540   1st Qu.:53.77   1st Qu.:0.620   1st Qu.:81.50   
 Median :  5.350   Median :63.19   Median :1.090   Median :85.36   
 Mean   :  6.032   Mean   :64.19   Mean   :1.318   Mean   :85.14   
 3rd Qu.: 14.840   3rd Qu.:73.32   3rd Qu.:1.780   3rd Qu.:89.66   
 Max.   : 28.130   Max.   :99.59   Max.   :8.280   Max.   :94.15   
 Wind_10_meter   Wind_50_meter   
 Min.   :1.520   Min.   : 2.780  
 1st Qu.:3.180   1st Qu.: 4.880  
 Median :4.080   Median : 5.950  
 Mean   :4.042   Mean   : 5.959  
 3rd Qu.:4.860   3rd Qu.: 6.960  
 Max.   :8.080   Max.   :10.790  
Code
view_North <- North %>%
  slice(1:10)

kable(view_North, digits = 2, align = "ccccccc", col.names = c("Year", "Month", "Latitude", "Longitude", "Temperature", "Humidity", "Precipitation", "Surface Pressure", "Wind 10 Meters", "Wind 50 Meters"), caption = "Northern Data") %>%
  kable_styling(font_size = 16)
Northern Data
Year Month Latitude Longitude Temperature Humidity Precipitation Surface Pressure Wind 10 Meters Wind 50 Meters
1990 NOV 43.25 -103.75 3.48 54.59 0.69 87.57 5.30 7.95
1990 JAN 43.25 -103.75 -1.23 64.91 0.13 87.29 5.90 8.62
1990 FEB 43.25 -103.75 -2.22 63.34 0.49 87.60 4.96 7.16
1990 MAR 43.25 -103.75 1.79 62.66 1.24 87.66 4.54 6.50
1990 APR 43.25 -103.75 7.32 57.72 1.78 87.56 4.28 6.03
1990 MAY 43.25 -103.75 11.66 59.12 2.78 87.45 4.49 6.32
1990 JUN 43.25 -103.75 20.12 47.00 1.33 87.55 4.55 6.61
1990 JUL 43.25 -103.75 22.43 47.81 2.41 87.90 3.38 5.03
1990 AUG 43.25 -103.75 22.72 47.12 1.01 87.90 3.29 4.93
1990 SEP 43.25 -103.75 18.85 45.72 1.11 88.01 3.91 5.89
Code
Weather_region_North <- North %>%
  mutate(Regions = case_when(
    Latitude >= 23.25 & Latitude <= 40.75 & Longitude >= -95.5 & Longitude <= -70.5 ~ 'Southeast',
    Latitude >= 25 & Latitude <= 37 & Longitude >= -114.75 & Longitude <= -95.6 ~ 'Southwest',
    Latitude >= 32.3 & Latitude <= 49 & Longitude >= -124.36 & Longitude <= -102 ~ 'West',
    Latitude >= 39.7 & Latitude <= 47.4 & Longitude >= -81 & Longitude <= -66 ~ 'Northeast',
    Latitude >= 35 & Latitude <= 49 & Longitude >= -104 & Longitude <= -80.5 ~ 'Midwest'
  ))

Weather_region_North

South

Code
region <- South %>%
pivot_longer(
  cols = c(NOV, JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, DEC),
  names_to = "MONTH",
  values_to = "Month_Average",
)
South <- tidy_function(region)

South <- South %>%
  select(Year, Month, Latitude, Longitude, Temperature, Humidity, Precipitation, Surface_Pressure, Wind_10_meter, Wind_50_meter)

summary(South)
      Year         Month              Latitude       Longitude     
 Min.   :1990   Length:84816       Min.   :32.25   Min.   :-91.25  
 1st Qu.:1997   Class :character   1st Qu.:33.62   1st Qu.:-89.25  
 Median :2005   Mode  :character   Median :35.00   Median :-86.75  
 Mean   :2005                      Mean   :35.00   Mean   :-86.75  
 3rd Qu.:2013                      3rd Qu.:36.38   3rd Qu.:-84.25  
 Max.   :2020                      Max.   :37.75   Max.   :-82.25  
  Temperature       Humidity     Precipitation    Surface_Pressure
 Min.   :-5.29   Min.   :36.84   Min.   : 0.010   Min.   : 92.41  
 1st Qu.: 8.10   1st Qu.:72.24   1st Qu.: 2.380   1st Qu.: 98.34  
 Median :15.73   Median :78.50   Median : 3.340   Median : 99.68  
 Mean   :15.46   Mean   :76.75   Mean   : 3.612   Mean   : 99.15  
 3rd Qu.:23.33   3rd Qu.:82.34   3rd Qu.: 4.570   3rd Qu.:100.43  
 Max.   :32.63   Max.   :92.29   Max.   :16.850   Max.   :102.22  
 Wind_10_meter   Wind_50_meter  
 Min.   :1.140   Min.   :2.360  
 1st Qu.:1.980   1st Qu.:3.880  
 Median :2.430   Median :4.520  
 Mean   :2.605   Mean   :4.626  
 3rd Qu.:3.100   3rd Qu.:5.260  
 Max.   :6.430   Max.   :9.270  
Code
view_South <- South %>%
  slice(1:10)

kable(view_South, digits = 2, align = "ccccccc", col.names = c("Year", "Month", "Latitude", "Longitude", "Temperature", "Humidity", "Precipitation", "Surface Pressure", "Wind 10 Meters", "Wind 50 Meters"), caption = "Southern Data") %>%
  kable_styling(font_size = 16)
Southern Data
Year Month Latitude Longitude Temperature Humidity Precipitation Surface Pressure Wind 10 Meters Wind 50 Meters
1990 NOV 32.25 -82.25 13.54 79.79 1.68 101.36 3.13 5.15
1990 JAN 32.25 -82.25 10.43 86.30 4.15 101.39 3.21 5.16
1990 FEB 32.25 -82.25 12.68 85.29 3.16 101.49 4.03 6.34
1990 MAR 32.25 -82.25 15.02 82.99 2.07 101.50 3.30 5.19
1990 APR 32.25 -82.25 17.33 73.48 1.24 101.13 3.53 5.58
1990 MAY 32.25 -82.25 23.49 64.33 2.01 100.85 3.49 5.38
1990 JUN 32.25 -82.25 28.00 58.58 1.52 100.91 3.20 4.89
1990 JUL 32.25 -82.25 29.27 61.62 3.32 100.95 3.30 5.03
1990 AUG 32.25 -82.25 28.28 68.83 4.06 100.90 2.13 3.45
1990 SEP 32.25 -82.25 26.26 58.85 0.97 100.96 2.71 4.34
Code
Weather_region_South <- South %>%
  mutate(Regions = case_when(
    Latitude >= 23.25 & Latitude <= 40.75 & Longitude >= -95.5 & Longitude <= -70.5 ~ 'Southeast',
    Latitude >= 25 & Latitude <= 37 & Longitude >= -114.75 & Longitude <= -95.6 ~ 'Southwest',
    Latitude >= 32.3 & Latitude <= 49 & Longitude >= -124.36 & Longitude <= -102 ~ 'West',
    Latitude >= 39.7 & Latitude <= 47.4 & Longitude >= -81 & Longitude <= -66 ~ 'Northeast',
    Latitude >= 35 & Latitude <= 49 & Longitude >= -104 & Longitude <= -80.5 ~ 'Midwest'
  ))

Weather_region_South

South California

Code
region <- SouthCali %>%
pivot_longer(
  cols = c(NOV, JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, DEC),
  names_to = "MONTH",
  values_to = "Month_Average",
)
South_California <- tidy_function(region)

South_California <- South_California %>%
  select(Year, Month, Latitude, Longitude, Temperature, Humidity, Precipitation, Surface_Pressure, Wind_10_meter, Wind_50_meter)

summary(South_California)
      Year         Month              Latitude       Longitude     
 Min.   :1990   Length:78120       Min.   :33.75   Min.   :-121.8  
 1st Qu.:1997   Class :character   1st Qu.:35.25   1st Qu.:-120.2  
 Median :2005   Mode  :character   Median :37.25   Median :-118.5  
 Mean   :2005                      Mean   :37.25   Mean   :-118.5  
 3rd Qu.:2013                      3rd Qu.:39.25   3rd Qu.:-116.8  
 Max.   :2020                      Max.   :40.75   Max.   :-115.2  
  Temperature       Humidity     Precipitation     Surface_Pressure
 Min.   :-8.91   Min.   :11.89   Min.   : 0.0000   Min.   : 73.88  
 1st Qu.: 7.29   1st Qu.:33.86   1st Qu.: 0.1100   1st Qu.: 82.98  
 Median :13.43   Median :49.53   Median : 0.4100   Median : 89.04  
 Mean   :13.38   Mean   :50.99   Mean   : 0.9714   Mean   : 89.33  
 3rd Qu.:19.72   3rd Qu.:66.72   3rd Qu.: 1.1300   3rd Qu.: 96.48  
 Max.   :35.71   Max.   :97.56   Max.   :19.2300   Max.   :102.32  
 Wind_10_meter  Wind_50_meter   
 Min.   :1.65   Min.   : 2.360  
 1st Qu.:2.80   1st Qu.: 3.900  
 Median :3.26   Median : 4.480  
 Mean   :3.44   Mean   : 4.632  
 3rd Qu.:3.79   3rd Qu.: 5.150  
 Max.   :9.93   Max.   :11.320  
Code
view_SouthCali <- South_California %>%
  slice(1:10)

kable(view_SouthCali, digits = 2, align = "ccccccc", col.names = c("Year", "Month", "Latitude", "Longitude", "Temperature", "Humidity", "Precipitation", "Surface Pressure", "Wind 10 Meters", "Wind 50 Meters"), caption = "South California Data") %>%
  kable_styling(font_size = 16)
South California Data
Year Month Latitude Longitude Temperature Humidity Precipitation Surface Pressure Wind 10 Meters Wind 50 Meters
1990 NOV 33.75 -115.25 15.08 28.55 0.05 97.24 4.21 6.12
1990 JAN 33.75 -115.25 9.52 44.28 0.36 97.38 3.46 5.05
1990 FEB 33.75 -115.25 10.93 38.61 0.16 97.32 3.84 5.48
1990 MAR 33.75 -115.25 16.89 31.98 0.09 96.99 3.46 4.86
1990 APR 33.75 -115.25 21.34 34.41 0.10 96.76 3.72 5.14
1990 MAY 33.75 -115.25 23.52 27.32 0.09 96.58 4.18 5.66
1990 JUN 33.75 -115.25 30.54 21.35 0.15 96.54 3.69 5.03
1990 JUL 33.75 -115.25 33.59 28.24 0.32 96.62 3.58 4.67
1990 AUG 33.75 -115.25 30.76 31.84 0.59 96.78 3.12 4.21
1990 SEP 33.75 -115.25 28.74 31.53 0.38 96.73 2.85 3.96
Code
Weather_region_SouthCali <- South_California %>%
  mutate(Regions = case_when(
    Latitude >= 23.25 & Latitude <= 40.75 & Longitude >= -95.5 & Longitude <= -70.5 ~ 'Southeast',
    Latitude >= 25 & Latitude <= 37 & Longitude >= -114.75 & Longitude <= -95.6 ~ 'Southwest',
    Latitude >= 32.3 & Latitude <= 49 & Longitude >= -124.36 & Longitude <= -102 ~ 'West',
    Latitude >= 39.7 & Latitude <= 47.4 & Longitude >= -81 & Longitude <= -66 ~ 'Northeast',
    Latitude >= 35 & Latitude <= 49 & Longitude >= -104 & Longitude <= -80.5 ~ 'Midwest'
  ))

Weather_region_SouthCali

Texas

Code
region <- Texas %>%
pivot_longer(
  cols = c(NOV, JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, DEC),
  names_to = "MONTH",
  values_to = "Month_Average",
)
Texas <- tidy_function(region)

Texas <- Texas %>%
  select(Year, Month, Latitude, Longitude, Temperature, Humidity, Precipitation, Surface_Pressure, Wind_10_meter, Wind_50_meter)

summary(Texas)
      Year         Month              Latitude       Longitude      
 Min.   :1990   Length:104160      Min.   :29.25   Min.   :-103.75  
 1st Qu.:1997   Class :character   1st Qu.:30.75   1st Qu.:-101.38  
 Median :2005   Mode  :character   Median :32.50   Median : -99.00  
 Mean   :2005                      Mean   :32.50   Mean   : -99.00  
 3rd Qu.:2013                      3rd Qu.:34.25   3rd Qu.: -96.62  
 Max.   :2020                      Max.   :35.75   Max.   : -94.25  
  Temperature       Humidity     Precipitation    Surface_Pressure
 Min.   :-2.62   Min.   :14.00   Min.   : 0.000   Min.   : 84.89  
 1st Qu.:10.66   1st Qu.:52.22   1st Qu.: 0.750   1st Qu.: 92.21  
 Median :18.42   Median :62.76   Median : 1.710   Median : 96.59  
 Mean   :17.99   Mean   :62.28   Mean   : 2.156   Mean   : 95.64  
 3rd Qu.:25.80   3rd Qu.:73.30   3rd Qu.: 3.050   3rd Qu.: 99.23  
 Max.   :35.35   Max.   :94.14   Max.   :33.700   Max.   :102.51  
 Wind_10_meter   Wind_50_meter  
 Min.   :1.220   Min.   :2.690  
 1st Qu.:3.840   1st Qu.:5.670  
 Median :4.470   Median :6.490  
 Mean   :4.348   Mean   :6.387  
 3rd Qu.:5.010   3rd Qu.:7.200  
 Max.   :7.200   Max.   :9.780  
Code
view_Texas <- Texas %>%
  slice(1:10)

kable(view_Texas, digits = 2, align = "ccccccc", col.names = c("Year", "Month", "Latitude", "Longitude", "Temperature", "Humidity", "Precipitation", "Surface Pressure", "Wind 10 Meters", "Wind 50 Meters"), caption = "Texas Data") %>%
  kable_styling(font_size = 16)
Texas Data
Year Month Latitude Longitude Temperature Humidity Precipitation Surface Pressure Wind 10 Meters Wind 50 Meters
1990 NOV 29.25 -100.25 16.35 68.49 1.11 97.75 3.91 6.00
1990 JAN 29.25 -100.25 11.95 59.48 0.54 97.73 3.83 5.90
1990 FEB 29.25 -100.25 14.51 57.53 2.57 97.67 4.33 6.40
1990 MAR 29.25 -100.25 17.19 68.09 1.73 97.56 4.81 6.83
1990 APR 29.25 -100.25 20.98 69.78 3.48 97.30 4.92 6.99
1990 MAY 29.25 -100.25 25.52 63.69 2.56 96.99 4.54 6.46
1990 JUN 29.25 -100.25 31.81 45.02 0.03 97.17 5.94 7.84
1990 JUL 29.25 -100.25 27.49 65.36 6.48 97.45 5.04 6.84
1990 AUG 29.25 -100.25 28.14 61.81 0.96 97.49 4.19 6.15
1990 SEP 29.25 -100.25 25.36 70.53 3.77 97.48 3.30 4.91
Code
Weather_region_Texas <- Texas %>%
  mutate(Regions = case_when(
    Latitude >= 23.25 & Latitude <= 40.75 & Longitude >= -95.5 & Longitude <= -70.5 ~ 'Southeast',
    Latitude >= 25 & Latitude <= 37 & Longitude >= -114.75 & Longitude <= -95.6 ~ 'Southwest',
    Latitude >= 32.3 & Latitude <= 49 & Longitude >= -124.36 & Longitude <= -102 ~ 'West',
    Latitude >= 39.7 & Latitude <= 47.4 & Longitude >= -81 & Longitude <= -66 ~ 'Northeast',
    Latitude >= 35 & Latitude <= 49 & Longitude >= -104 & Longitude <= -80.5 ~ 'Midwest'
  ))

Weather_region_Texas

Washington

Code
region <- Washington %>%
pivot_longer(
  cols = c(NOV, JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, DEC),
  names_to = "MONTH",
  values_to = "Month_Average",
)
Washington <- tidy_function(region)

Washington <- Washington %>%
  select(Year, Month, Latitude, Longitude, Temperature, Humidity, Precipitation, Surface_Pressure, Wind_10_meter, Wind_50_meter)

summary(Washington)
      Year         Month              Latitude       Longitude     
 Min.   :1990   Length:82212       Min.   :41.75   Min.   :-122.8  
 1st Qu.:1997   Class :character   1st Qu.:43.25   1st Qu.:-120.8  
 Median :2005   Mode  :character   Median :44.75   Median :-118.8  
 Mean   :2005                      Mean   :44.75   Mean   :-118.8  
 3rd Qu.:2013                      3rd Qu.:46.25   3rd Qu.:-116.8  
 Max.   :2020                      Max.   :47.75   Max.   :-114.8  
  Temperature         Humidity     Precipitation   Surface_Pressure
 Min.   :-14.040   Min.   :20.81   Min.   : 0.00   Min.   :76.13   
 1st Qu.:  0.670   1st Qu.:55.59   1st Qu.: 0.63   1st Qu.:84.95   
 Median :  6.970   Median :70.02   Median : 1.35   Median :87.59   
 Mean   :  7.653   Mean   :68.57   Mean   : 1.90   Mean   :88.43   
 3rd Qu.: 14.840   3rd Qu.:82.60   3rd Qu.: 2.46   3rd Qu.:92.25   
 Max.   : 28.950   Max.   :99.83   Max.   :19.67   Max.   :99.34   
 Wind_10_meter   Wind_50_meter  
 Min.   :1.180   Min.   :1.960  
 1st Qu.:2.160   1st Qu.:3.700  
 Median :2.860   Median :4.420  
 Mean   :2.923   Mean   :4.509  
 3rd Qu.:3.550   3rd Qu.:5.190  
 Max.   :6.830   Max.   :9.480  
Code
view_Washington <- Washington %>%
  slice(1:10)

kable(view_Washington, digits = 2, align = "ccccccc", col.names = c("Year", "Month", "Latitude", "Longitude", "Temperature", "Humidity", "Precipitation", "Surface Pressure", "Wind 10 Meters", "Wind 50 Meters"), caption = "Washington Data") %>%
  kable_styling(font_size = 16)
Washington Data
Year Month Latitude Longitude Temperature Humidity Precipitation Surface Pressure Wind 10 Meters Wind 50 Meters
1990 NOV 41.75 -114.75 0.34 59.24 0.73 81.59 4.81 6.77
1990 JAN 41.75 -114.75 -4.07 78.51 1.28 81.30 5.15 7.25
1990 FEB 41.75 -114.75 -4.71 70.26 0.56 81.31 4.92 6.56
1990 MAR 41.75 -114.75 1.91 61.00 0.90 81.29 4.47 6.01
1990 APR 41.75 -114.75 8.08 52.46 1.38 81.25 4.31 5.77
1990 MAY 41.75 -114.75 8.88 49.42 1.40 81.13 4.24 5.68
1990 JUN 41.75 -114.75 16.01 40.19 0.74 81.46 3.93 5.37
1990 JUL 41.75 -114.75 21.67 32.96 0.18 81.65 3.37 4.63
1990 AUG 41.75 -114.75 19.79 34.71 0.86 81.70 3.22 4.41
1990 SEP 41.75 -114.75 17.79 35.25 0.22 81.74 3.07 4.32
Code
Weather_region_Washington <- Washington %>%
  mutate(Regions = case_when(
    Latitude >= 23.25 & Latitude <= 40.75 & Longitude >= -95.5 & Longitude <= -70.5 ~ 'Southeast',
    Latitude >= 25 & Latitude <= 37 & Longitude >= -114.75 & Longitude <= -95.6 ~ 'Southwest',
    Latitude >= 32.3 & Latitude <= 49 & Longitude >= -124.36 & Longitude <= -102 ~ 'West',
    Latitude >= 39.7 & Latitude <= 47.4 & Longitude >= -81 & Longitude <= -66 ~ 'Northeast',
    Latitude >= 35 & Latitude <= 49 & Longitude >= -104 & Longitude <= -80.5 ~ 'Midwest'
  ))

Weather_region_Washington

West Virgina

Code
region <- WestV %>%
pivot_longer(
  cols = c(NOV, JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, DEC),
  names_to = "MONTH",
  values_to = "Month_Average",
)
West_Virginia <- tidy_function(region)

West_Virginia <- West_Virginia %>%
  select(Year, Month, Latitude, Longitude, Temperature, Humidity, Precipitation, Surface_Pressure, Wind_10_meter, Wind_50_meter)

summary(West_Virginia)
      Year         Month              Latitude       Longitude     
 Min.   :1990   Length:74400       Min.   :38.75   Min.   :-92.25  
 1st Qu.:1997   Class :character   1st Qu.:39.75   1st Qu.:-89.88  
 Median :2005   Mode  :character   Median :41.00   Median :-87.50  
 Mean   :2005                      Mean   :41.00   Mean   :-87.50  
 3rd Qu.:2013                      3rd Qu.:42.25   3rd Qu.:-85.12  
 Max.   :2020                      Max.   :43.25   Max.   :-82.75  
  Temperature        Humidity     Precipitation    Surface_Pressure
 Min.   :-15.01   Min.   :42.91   Min.   : 0.070   Min.   : 96.84  
 1st Qu.:  1.16   1st Qu.:74.30   1st Qu.: 1.620   1st Qu.: 98.52  
 Median : 10.68   Median :78.66   Median : 2.470   Median : 98.91  
 Mean   : 10.17   Mean   :78.26   Mean   : 2.712   Mean   : 98.89  
 3rd Qu.: 19.68   3rd Qu.:82.78   3rd Qu.: 3.500   3rd Qu.: 99.27  
 Max.   : 31.10   Max.   :96.86   Max.   :11.770   Max.   :100.75  
 Wind_10_meter   Wind_50_meter  
 Min.   :1.230   Min.   : 2.73  
 1st Qu.:3.720   1st Qu.: 5.64  
 Median :4.600   Median : 6.69  
 Mean   :4.527   Mean   : 6.55  
 3rd Qu.:5.280   3rd Qu.: 7.43  
 Max.   :9.630   Max.   :10.79  
Code
view_WestV <- West_Virginia %>%
  slice(1:10)

kable(view_WestV, digits = 2, align = "ccccccc", col.names = c("Year", "Month", "Latitude", "Longitude", "Temperature", "Humidity", "Precipitation", "Surface Pressure", "Wind 10 Meters", "Wind 50 Meters"), caption = "West Virginia Data") %>%
  kable_styling(font_size = 16)
West Virginia Data
Year Month Latitude Longitude Temperature Humidity Precipitation Surface Pressure Wind 10 Meters Wind 50 Meters
1990 NOV 38.75 -82.75 7.51 78.61 1.90 99.06 2.12 4.52
1990 JAN 38.75 -82.75 2.18 85.99 2.72 98.83 2.79 5.31
1990 FEB 38.75 -82.75 3.81 84.92 3.60 99.03 2.87 5.39
1990 MAR 38.75 -82.75 7.16 81.56 1.94 99.27 2.28 4.45
1990 APR 38.75 -82.75 10.65 76.54 2.76 98.84 2.13 4.24
1990 MAY 38.75 -82.75 15.35 80.81 6.58 98.51 2.16 4.49
1990 JUN 38.75 -82.75 20.81 80.24 2.98 98.66 1.84 3.98
1990 JUL 38.75 -82.75 23.19 77.11 3.71 98.81 1.52 3.40
1990 AUG 38.75 -82.75 23.23 68.86 3.53 98.85 1.28 2.81
1990 SEP 38.75 -82.75 19.94 70.16 2.86 98.81 1.60 3.48
Code
Weather_region_WestV <- West_Virginia %>%
  mutate(Regions = case_when(
    Latitude >= 23.25 & Latitude <= 40.75 & Longitude >= -95.5 & Longitude <= -70.5 ~ 'Southeast',
    Latitude >= 25 & Latitude <= 37 & Longitude >= -114.75 & Longitude <= -95.6 ~ 'Southwest',
    Latitude >= 32.3 & Latitude <= 49 & Longitude >= -124.36 & Longitude <= -102 ~ 'West',
    Latitude >= 39.7 & Latitude <= 47.4 & Longitude >= -81 & Longitude <= -66 ~ 'Northeast',
    Latitude >= 35 & Latitude <= 49 & Longitude >= -104 & Longitude <= -80.5 ~ 'Midwest'
  ))

Weather_region_WestV

State Economy data

The economic data is pulled from the Bureau of Economic Analysis (Analysis, n.d.). This data is the ins, outs, and the difference between the former two in income by state. The data ranges from 1990 to 2020 and covers every state in the US.

Code
# Reading in economic data

Economy <- read.csv("_data/Economy.csv")

# Renaming the columns to remove the X
Economy <- Economy %>%
  dplyr::rename('1990' = X1990) %>%
  dplyr::rename('1991' = X1991) %>%
  dplyr::rename('1992' = X1992) %>%
  dplyr::rename('1993' = X1993) %>%
  dplyr::rename('1994' = X1994) %>%
  dplyr::rename('1995' = X1995) %>%
  dplyr::rename('1996' = X1996) %>%
  dplyr::rename('1997' = X1997) %>%
  dplyr::rename('1998' = X1998) %>%
  dplyr::rename('1999' = X1999) %>%
  dplyr::rename('2000' = X2000) %>%
  dplyr::rename('2001' = X2001) %>%
  dplyr::rename('2002' = X2002) %>%
  dplyr::rename('2003' = X2003) %>%
  dplyr::rename('2004' = X2004) %>%
  dplyr::rename('2005' = X2005) %>%
  dplyr::rename('2006' = X2006) %>%
  dplyr::rename('2007' = X2007) %>%
  dplyr::rename('2008' = X2008) %>%
  dplyr::rename('2009' = X2009) %>%
  dplyr::rename('2010' = X2010) %>%
  dplyr::rename('2011' = X2011) %>%
  dplyr::rename('2012' = X2012) %>%
  dplyr::rename('2013' = X2013) %>%
  dplyr::rename('2014' = X2014) %>%
  dplyr::rename('2015' = X2015) %>%
  dplyr::rename('2016' = X2016) %>%
  dplyr::rename('2017' = X2017) %>%
  dplyr::rename('2018' = X2018) %>%
  dplyr::rename('2019' = X2019) %>%
  dplyr::rename('2020' = X2020) 

# Pivoting to combine all the years into one column
Economy <- Economy %>%
pivot_longer(
  cols = c('1990', '1991', '1992', '1993', '1994', '1995', '1996', '1997', '1998', '1999', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020'),
  names_to = "Year",
  values_to = "Yearly_Fianace",
)

## Change from char to numeric
Economy$Year <- as.numeric(Economy$Year)

# Changing the finance column to be in millions
Economy <- Economy %>%
  mutate(Year_Money_Millions = Yearly_Fianace/1000)

Economy <- Economy %>%
  select(State, Year, Year_Money_Millions, Description) %>%
  filter(Description == "Adjustment for residence")

Economy <- Economy %>%
  mutate(Regions = case_when(
    Latitude >= 23.25 & Latitude <= 40.75 & Longitude >= -95.5 & Longitude <= -70.5 ~ 'Southeast',
    Latitude >= 25 & Latitude <= 37 & Longitude >= -114.75 & Longitude <= -95.6 ~ 'Southwest',
    Latitude >= 32.3 & Latitude <= 49 & Longitude >= -124.36 & Longitude <= -102 ~ 'West',
    Latitude >= 39.7 & Latitude <= 47.4 & Longitude >= -81 & Longitude <= -66 ~ 'Northeast',
    Latitude >= 35 & Latitude <= 49 & Longitude >= -104 & Longitude <= -80.5 ~ 'Midwest'
  ))
Error in eval_tidy(pair$lhs, env = default_env): object 'Latitude' not found

References

  • Analysis, B. o. (n.d.). Regional Economic Accounts: Download. Retrieved from BEA: https://apps.bea.gov/regional/downloadzip.cfm

  • Research, NASA Langley. The POWER Project. 08 May 2021. 21 February 2022. https://power.larc.nasa.gov.

(“These data were obtained from the NASA Langley Research Center (LaRC) POWER Project funded through the NASA Earth Science/Applied Science Program.”)