Created
February 17, 2023 20:22
-
-
Save dhersz/3271d60c474cfd694dde5157f5eb5615 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(accessibility) | |
library(ggplot2) | |
data_dir <- system.file("extdata", package = "accessibility") | |
travel_matrix <- readRDS(file.path(data_dir, "travel_matrix.rds")) | |
land_use_data <- readRDS(file.path(data_dir, "land_use_data.rds")) | |
access <- cumulative_cutoff( | |
travel_matrix, | |
land_use_data, | |
cutoff = 1:120, | |
opportunity = "jobs", | |
travel_cost = "travel_time" | |
) | |
access | |
# ideally we'd have to weigh by each origin population here, but you get the | |
# point | |
avg_access <- access[, .(avg_access = mean(jobs)), by = cutoff] | |
total_jobs <- sum(land_use_data$jobs) | |
ggplot(avg_access) + | |
geom_line(aes(cutoff, avg_access)) + | |
scale_y_continuous( | |
labels = scales::label_percent(scale = 100 / total_jobs) | |
) + | |
labs( | |
x = "Travel time cutoff", | |
y = "Avg. accessibility\n(% of total jobs in the study area)" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment