I have made this project draft 

---
title: "Project Proposal: Analysis of Global Temperature Variations"
author: "Arnesh Tarachandani"
date: "2024-07-27"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
```

# Introduction

This study aims to investigate whether urbanization influences the average temperature variations in different cities across the world over the past decade. To address this question, we utilize temperature anomaly data from various sources, including global, hemispheric, and zonal means.

# Data

We will use the following datasets:
- **Global-mean monthly, seasonal, and annual means (2002-present):** Provides average temperature anomalies globally.
- **Northern Hemisphere-mean monthly, seasonal, and annual means (2002-present):** Provides temperature anomalies for the Northern Hemisphere.
- **Southern Hemisphere-mean monthly, seasonal, and annual means (2002-present):** Provides temperature anomalies for the Southern Hemisphere.
- **Zonal annual means (2002-present):** Provides temperature anomalies for different latitude zones.

# Summaries of the Data

## Numerical Summaries

To understand the data, we first compute the following numerical summaries:
- Mean and median temperature anomalies for global, Northern Hemisphere, and Southern Hemisphere datasets.
- Standard deviation and range of temperature anomalies to measure variability.

```{r}
library(readr)
library(dplyr)
library(tidyr)
# Load data
global_data <- read_csv("GLB.Ts+dSST (1).csv", skip = 1, na = "")
northern_data <- read_csv("NH.Ts+dSST.csv", skip = 1, na = "")
southern_data <- read_csv("SH.Ts+dSST.csv", skip = 1, na = "")
zonal_data <- read_csv("ZonAnn.Ts+dSST.csv", skip = 1, na = "")
clean_data <- function(dataset) {
  dataset %>%
    mutate(across(Jan:Dec, ~as.numeric(.))) %>%
    filter(!is.na(Jan) | !is.na(Feb) | !is.na(Mar) | !is.na(Apr) | !is.na(May) |
           !is.na(Jun) | !is.na(Jul) | !is.na(Aug) | !is.na(Sep) | !is.na(Oct) |
           !is.na(Nov) | !is.na(Dec))
}
clean_global_data <- clean_data(global_data)
clean_northern_data <- clean_data(northern_data)
clean_southern_data <- clean_data(southern_data)

compute_summaries <- function(dataset) {
  dataset %>%
    select(Jan:Dec) %>%
    pivot_longer(cols = everything(), names_to = "month", values_to = "anomaly") %>%
    summarise(
      mean_anomaly = mean(anomaly, na.rm = TRUE),
      median_anomaly = median(anomaly, na.rm = TRUE),
      sd_anomaly = sd(anomaly, na.rm = TRUE),
      range_anomaly = max(anomaly, na.rm = TRUE) - min(anomaly, na.rm = TRUE)
    )
}

# Compute summaries for each dataset
global_summary <- compute_summaries(clean_global_data)
northern_summary <- compute_summaries(clean_northern_data)
southern_summary <- compute_summaries(clean_southern_data)

print("Global Summary:")
print(global_summary)

print("Northern Hemisphere Summary:")
print(northern_summary)

print("Southern Hemisphere Summary:")
print(southern_summary)

```

## Graphical Summaries

Graphical displays are essential for visualizing the trends and patterns in the data. The following plots provide a clear depiction of the temperature anomalies over time:

### Time Series Plot

A time series plot of global temperature anomalies from 2002 to present.

```{r time-series-plot}
library(readr)
library(dplyr)
library(ggplot2)
global_data <- read_csv("GLB.Ts+dSST (1).csv", skip = 1, na = "")

clean_global_data <- global_data %>%
  mutate(across(Jan:Dec, as.numeric)) %>%
  mutate(`J-D` = as.numeric(`J-D`)) %>%
  filter(!is.na(Year) & !is.na(`J-D`)) 

clean_global_data$Year <- as.numeric(clean_global_data$Year)

global_data_filtered <- clean_global_data %>% filter(Year >= 2002)

ggplot(global_data_filtered, aes(x = Year, y = `J-D`)) +
  geom_line(color = "blue") +
  geom_point(color = "red") +
  labs(
    title = "Global Temperature Anomalies (2002 - Present)",
    x = "Year",
    y = "Temperature Anomaly (°C)"
  ) +
  scale_y_continuous(breaks = seq(-1, 1, by = 0.05)) +
  theme_minimal() +
  geom_smooth(method = "lm", col = "black", se = FALSE) +  # Add a trend line
  theme(
    plot.title = element_text(hjust = 0.5),
    axis.text = element_text(size = 12),
    axis.title = element_text(size = 14)
  ) 

```

This plot shows the trends in global temperature anomalies over the specified period and supports the conclusion that there is a noticeable increase in temperature anomalies, possibly influenced by urbanization and other factors.

# Discussion

## Interpretation of Results

The analysis indicates that there has been a consistent increase in temperature anomalies globally over the past decade. This supports the hypothesis that factors such as urbanization may be contributing to these temperature changes.

### Potential Shortcomings

- **Data Limitations:** The datasets used may have inherent biases or limitations, such as incomplete coverage of certain regions or inconsistencies in measurement techniques. Additionally, the resolution of the data may not be sufficient to capture local variations influenced by urbanization.
- **External Factors:** Other factors such as greenhouse gas emissions, deforestation, and natural climate variability could also influence temperature anomalies. These factors make it challenging to isolate the impact of urbanization alone on temperature changes.

### Future Directions

#### Practical Plan for a Student

To further investigate the influence of urbanization on temperature variations, a student can follow these practical steps:

1. **Expand Data Collection:**
   - **Additional Data Sources:** Collect more granular data on urbanization metrics, such as population density, rate of construction, and availability of green spaces. Publicly available datasets from sources like the World Bank, United Nations, and local government databases can be useful.
   - **Satellite Data:** Use satellite data for more accurate measurements of land surface temperatures. Platforms like NASA's Earth Observing System Data and Information System (EOSDIS) provide access to such data.

2. **Refine Analysis Methods:**
   - **Multivariate Analysis:** Conduct a multivariate analysis to include other factors like greenhouse gas emissions and land use changes. This approach helps in understanding the combined effects of multiple variables on temperature anomalies.
   - **Machine Learning Models:** Implement machine learning models to better predict temperature anomalies based on urbanization metrics. Models such as Random Forest or Gradient Boosting can be used to analyze the data and identify patterns.

3. **Data Visualization:**
   - **Interactive Maps:** Create interactive maps to visualize temperature anomalies and urbanization metrics. Tools like Google Earth Engine or QGIS can be used to create such visualizations.
   - **Time-Series Analysis:** Perform time-series analysis to detect trends and seasonal patterns in the temperature data. Libraries like `forecast` in R or `prophet` in Python can be helpful.

4. **Community Engagement:**
   - **Citizen Science Projects:** Engage the community in data collection through citizen science projects. Platforms like Zooniverse or local initiatives can help gather additional data on urbanization and its impact.
   - **Workshops and Presentations:** Conduct workshops and presentations to share findings with local communities and stakeholders. This helps in raising awareness and gaining insights from different perspectives.

#### New Questions and Data Collection

- **Specific Urban Practices:** Investigate whether specific urbanization practices, such as the extent of green spaces or the type of building materials used, have a more significant impact on temperature variations.
- **Temporal Changes:** Study how changes in urbanization practices over time correlate with temperature anomalies.
- **Local Climate Policies:** Analyze the effectiveness of local climate policies in mitigating the impact of urbanization on temperature variations.

## Primary Conclusions

The primary conclusion of this study is that there is a significant upward trend in global temperature anomalies over the past decade, which may be influenced by urbanization and other factors. The evidence supporting this conclusion includes numerical summaries and graphical representations of the temperature anomaly data.

# References

GISTEMP Team, 2024: GISS Surface Temperature Analysis (GISTEMP), version 4. NASA Goddard Institute for Space Studies. Dataset accessed 20YY-MM-DD at https://data.giss.nasa.gov/gistemp/.
Lenssen, N., G. Schmidt, J. Hansen, M. Menne, A. Persin, R. Ruedy, and D. Zyss, 2019: Improvements in the GISTEMP uncertainty model. J. Geophys. Res. Atmos., 124, no. 12, 6307-6326, doi:10.1029/2018JD029522.