rm(list=ls())
# Load necessary libraries
# install.packages("ggplot2")
library(ggplot2)

# Number of regions
n <- 500 

# Simulate latitude midpoints for regions (from -90 to 90 degrees)
latitude_midpoints <- runif(n, min=-90, max=90)

# Simulate rate of change of elevational width 
# (hypothetically assuming that regions closer to the poles or equator have more variable elevation changes)
elevation_change_rate <- rnorm(n, mean=1.5 - 1.0 * abs(latitude_midpoints)/90, sd=0.2)

# Simulate mean temperatures 
# (assuming regions near equator are warmer and those near poles are cooler)
mean_temperature <- rnorm(n, mean=30 - abs(latitude_midpoints)/3, sd=5)

# Combine into a dataframe
regions_data <- data.frame(
  LatitudeMidpoint = latitude_midpoints,
  ElevationChangeRate = elevation_change_rate,
  MeanTemperature = mean_temperature
)

# Example Plot: Latitude vs. Elevation Change Rate
ggplot(regions_data, aes(x=LatitudeMidpoint, y=ElevationChangeRate)) +
  geom_point(alpha=0.6) +
  labs(title="Latitude Midpoint vs. Elevation Change Rate", 
       x="Latitude Midpoint", 
       y="Rate of Change in Elevational Width") +
  theme_minimal()
