cooler_map<- tm_shape(shapefile_cooler) +tm_fill(col = "trip_freq.y")+ tm_layout(title = "Cooler Trip Map")
warmer_map<- tm_shape(shapefile_warmer) +tm_fill(col = "trip_freq.y")+ tm_layout(title = "Warmer Trip Map")

# Create a layout with two maps in a row
layout <- tmap_arrange(
  cooler_map, warmer_map,
  nrow = 1, ncol = 2,  # Arrange the maps in a single row
  widths = c(0.5, 0.5)  # Adjust the width of each map
)

# Plot the maps side by side
tmap_arrange(layout = layout)

diff_trip <- merge(cooler, warmer, by.x = "dest_id",by.y = "dest_id")
diff_trip$diff_trip <- diff_trip$trip_freq.y -diff_trip$trip_freq.x
diff_trip$dest_id<-as.character(diff_trip$dest_id)
shapefile_diff_trip <- merge(shapefile, diff_trip, by.x = "GEOID",by.y = "dest_id")

tm_shape(shapefile_diff_trip) +tm_fill(col = "diff_trip")+ tm_layout(title = "Warmer-Cooler")
## Variable(s) "diff_trip" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.

cooler_home <- fread('./city_project_data/stayhome_07_24_2019.txt')
warmer_home <- fread('./city_project_data/stayhome_07_31_2019.txt')

cooler_home$mean_home_dwell_time <-cooler_home$mean_home_dwell_time/60
warmer_home$mean_home_dwell_time <-warmer_home$mean_home_dwell_time/60

cooler_home$GEOID<-as.character(cooler_home$GEOID)
warmer_home$GEOID<-as.character(warmer_home$GEOID)

shapefile_cooler_home <- merge(shapefile, cooler_home, by.x = "GEOID",by.y = "GEOID")
shapefile_warmer_home <- merge(shapefile, warmer_home, by.x = "GEOID",by.y = "GEOID")
cooler_home_map<- tm_shape(shapefile_cooler_home) +tm_fill(col = "mean_home_dwell_time")+ tm_layout(title = "Cooler Stayhome Map")
warmer_home_map<- tm_shape(shapefile_warmer_home) +tm_fill(col = "mean_home_dwell_time")+ tm_layout(title = "Warmer Stayhome Map")

# Create a layout with two maps in a row
layout <- tmap_arrange(
  cooler_home_map, warmer_home_map,
  nrow = 1, ncol = 2,  # Arrange the maps in a single row
  widths = c(0.5, 0.5)  # Adjust the width of each map
)

# Plot the maps side by side
tmap_arrange(layout = layout)

diff_home <- merge(cooler_home, warmer_home, by.x = "GEOID",by.y = "GEOID")
diff_home$diff_home <- diff_home$mean_home_dwell_time.y -diff_home$mean_home_dwell_time.x

shapefile_diff_home <- merge(shapefile, diff_home, by.x = "GEOID",by.y = "GEOID")

tm_shape(shapefile_diff_home) +tm_fill(col = "diff_home")+ tm_layout(title = "Warmer-Cooler")
## Variable(s) "diff_home" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.