2025-04-01

Seattle Weather Analyses

Original Data VS Data Manipulation

-Years: 2012-2015

-Removed Columns: Wind

-Added Columns: Seasons

-Converted Columns: Temperature (Celsius to Fahrenheit), Precipitation (millimeters to inches)

##         date precipitation temp_max temp_min wind weather
## 1 2012-01-01           0.0     12.8      5.0  4.7 drizzle
## 2 2012-01-02          10.9     10.6      2.8  4.5    rain
## 3 2012-01-03           0.8     11.7      7.2  2.3    rain
##         date weather precipitation_in temp_max_F temp_min_F avg_temp_F season
## 1 2012-01-01 drizzle       0.00000000      55.04      41.00      48.02 Winter
## 2 2012-01-02    rain       0.42913386      51.08      37.04      44.06 Winter
## 3 2012-01-03    rain       0.03149606      53.06      44.96      49.01 Winter

Data Manipulation

# Convert precipitation from millimeters to inches
Seattle_Weather$precipitation_in <- Seattle_Weather$precipitation / 25.4

# Convert Celsius columns to Fahrenheit
Seattle_Weather$temp_max_F <- (Seattle_Weather$temp_max * 9/5) + 32
Seattle_Weather$temp_min_F <- (Seattle_Weather$temp_min * 9/5) + 32
Seattle_Weather$avg_temp_F <- (Seattle_Weather$temp_max_F + Seattle_Weather$temp_min_F) / 2

# Ensure the date column is in date format
Seattle_Weather$date <- as.Date(Seattle_Weather$date)

# Create a new season column based on the month
Seattle_Weather$season <- with(Seattle_Weather, 
  ifelse(format(date, "%m") %in% c("03", "04", "05"), "Spring",
  ifelse(format(date, "%m") %in% c("06", "07", "08"), "Summer",
  ifelse(format(date, "%m") %in% c("09", "10", "11"), "Fall", "Winter"))))

# Remove columns if they exist
 Seattle_Weather_new <- Seattle_Weather %>%
  select(-temp_max, -temp_min, -precipitation, -wind)

Let’s Look At the Data ~ Seattle 2012

We will look at Astronomical Seasons to help us examine the first 7 days of a new season during 2012.

Spring Data

##          date weather precipitation_in temp_max_F temp_min_F avg_temp_F season
## 80 2012-03-20    rain        0.1417323      46.04      35.96      41.00 Spring
## 81 2012-03-21    rain        0.0511811      48.02      33.98      41.00 Spring
## 82 2012-03-22    rain        0.1614173      50.00      35.06      42.53 Spring
## 83 2012-03-23     sun        0.0000000      53.96      33.08      43.52 Spring
## 84 2012-03-24     sun        0.0000000      59.00      37.94      48.47 Spring
## 85 2012-03-25    rain        0.0000000      55.94      35.96      45.95 Spring
## 86 2012-03-26 drizzle        0.0000000      55.04      42.98      49.01 Spring

Summer Data

##           date weather precipitation_in temp_max_F temp_min_F avg_temp_F season
## 172 2012-06-20     sun       0.00000000      75.92      50.00      62.96 Summer
## 173 2012-06-21     sun       0.00000000      75.02      53.06      64.04 Summer
## 174 2012-06-22    rain       0.61811024      57.02      53.06      55.04 Summer
## 175 2012-06-23    rain       0.33858268      60.08      48.92      54.50 Summer
## 176 2012-06-24 drizzle       0.00000000      66.92      48.92      57.92 Summer
## 177 2012-06-25    rain       0.01968504      66.92      51.98      59.45 Summer
## 178 2012-06-26    rain       0.00000000      64.94      51.08      58.01 Summer

Seattle 2012

Fall Data

##           date weather precipitation_in temp_max_F temp_min_F avg_temp_F season
## 266 2012-09-22    rain       0.01181102      66.92      53.06      59.99   Fall
## 267 2012-09-23     fog       0.00000000      66.92      50.00      58.46   Fall
## 268 2012-09-24     fog       0.00000000      69.98      50.00      59.99   Fall
## 269 2012-09-25     sun       0.00000000      66.92      51.98      59.45   Fall
## 270 2012-09-26 drizzle       0.00000000      66.92      48.92      57.92   Fall
## 271 2012-09-27 drizzle       0.00000000      73.04      50.00      61.52   Fall
## 272 2012-09-28    rain       0.00000000      77.00      53.96      65.48   Fall

Winter Data

##           date weather precipitation_in temp_max_F temp_min_F avg_temp_F season
## 356 2012-12-21    rain       0.07086614      46.94      28.94      37.94 Winter
## 357 2012-12-22    rain       0.12992126      46.94      39.02      42.98 Winter
## 358 2012-12-23    rain       0.25984252      44.96      37.94      41.45 Winter
## 359 2012-12-24    rain       0.01181102      42.08      37.04      39.56 Winter
## 360 2012-12-25    snow       0.53149606      42.08      37.04      39.56 Winter
## 361 2012-12-26    rain       0.18110236      44.06      37.94      41.00 Winter
## 362 2012-12-27    rain       0.16141732      46.04      37.94      41.99 Winter

Seasonal Comparisons

1. Which season had more total rainfall, spring or fall?

Note: Precipitation for this data set is all forms of water such as rain, sleet, snow, hail, or drizzle

Seasonal Comparisons

2. What was the average temperature in each season?

## Spring - Average Temperature: 52.273 °F | Median Temperature: 51.53 °F 
## Summer - Average Temperature: 66.755 °F | Median Temperature: 66.47 °F 
## Fall - Average Temperature: 54.729 °F | Median Temperature: 55.265 °F 
## Winter - Average Temperature: 42.859 °F | Median Temperature: 43.43 °F

Temperature vs. Rainfall Correlations

Spring

## `geom_smooth()` using formula = 'y ~ x'

Temperature vs. Rainfall Correlations

Summer

## `geom_smooth()` using formula = 'y ~ x'

Temperature vs. Rainfall Correlations

Fall

## `geom_smooth()` using formula = 'y ~ x'

Temperature vs. Rainfall Correlations

Winter

## `geom_smooth()` using formula = 'y ~ x'

Yearly Trends

Yearly Trends

Review

Data Manipulation

  • Removed Columns: Wind

  • Added Columns: Seasons

  • Converted Columns: Temperature (Celsius to Fahrenheit), Precipitation (millimeters to inches)

  • Columns: Date | weather | precipitation_in | temp_max_F | tempe_min_F | avg_temp_F | season

Review

Seasonal Comparisons

1.Which season had more total rainfall, spring or fall?

  • From 2012 to 2015 we can observe that there was more precipitation in fall than spring

  • Spring: 46.814961 inches

  • Fall: 54.385827 inches

2.What was the average temperature in each season?

  • Spring - Average Temperature: 52.273 °F | Median Temperature: 51.53 °F

  • Summer - Average Temperature: 66.755 °F | Median Temperature: 66.47 °F

  • Fall - Average Temperature: 54.729 °F | Median Temperature: 55.265 °F

  • Winter - Average Temperature: 42.859 °F | Median Temperature: 43.43 °F

Review

Rain VS Temperature

  • Spring - Correlation: r= -0.24

  • Summer - Correlation: r= -0.21

  • Fall - Correlation: r= -0.07

  • Winter - Correlation: r= 0.25

Yearly Trends

1.Which year had the highest average temperature?

- The year with the highest average temperature is: 2015 with an average temperature of 55.64 °F

2.Which year had the most rain?

- The year with the most rain is: 2014 with a total rainfall of 48.54 inches