if (FALSE) { # identical(tolower(Sys.getenv("NOT_CRAN")), "true")
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 = 30,
opportunity = "jobs",
travel_cost = "travel_time"
)
ti <- theil_t(
access,
sociodemographic_data = land_use_data,
opportunity = "jobs",
population = "population"
)
ti
# to calculate inequality between and within income deciles, we pass
# "income_decile" to socioeconomic_groups.
# some cells, however, are classified as in the decile NA because their
# income per capita is NaN, as they don't have any population. we filter
# these cells from our accessibility data, otherwise the output would include
# NA values (note that subsetting the data like this doesn't affect the
# assumption that groups are completely exhaustive, because cells with NA
# income decile don't have any population)
na_decile_ids <- land_use_data[is.na(land_use_data$income_decile), ]$id
access <- access[! access$id %in% na_decile_ids, ]
sociodem_data <- land_use_data[! land_use_data$id %in% na_decile_ids, ]
ti <- theil_t(
access,
sociodemographic_data = sociodem_data,
opportunity = "jobs",
population = "population",
socioeconomic_groups = "income_decile"
)
ti
}
Run the code above in your browser using DataLab