Created
March 29, 2024 00:27
-
-
Save soodoku/9df5b06a3865c4dfa7880cfeae38c0fb to your computer and use it in GitHub Desktop.
Skew in Village Pop. in India With Implications for Optimal Strategy to Reach Out
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(readr) | |
shrug <- read_csv("/Users/soodoku/Downloads/shrug-vd11-csv/pc11_vd_clean_shrid.csv") | |
# Take out missing from village pop (just 1) and sort | |
t_pop <- shrug$pc11_vd_t_p[!is.na(shrug$pc11_vd_t_p)] | |
sorted_values <- sort(t_pop, decreasing = TRUE) | |
# We have like 570k villages. 50k villages have ... | |
sum(sorted_values[1:50000])/sum(sorted_values) | |
# [1] 0.3720554 | |
# Let's do it more systematically | |
percentiles <- seq(10, 100, by = 10) | |
proportions <- length(percentiles) | |
for (i in seq_along(percentiles)) { | |
index <- round(length(sorted_values) * (percentiles[i]/100)) | |
percentile_sum <- sum(sorted_values[1:index]) | |
proportions[i] <- percentile_sum / sum(t_pop) | |
} | |
# Combine percentiles and proportions into a data frame for easier interpretation | |
result <- data.frame(Percentile = percentiles, Proportion = proportions) | |
# Print the result | |
print(result) |
Author
soodoku
commented
Mar 29, 2024

Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment