njtierney / maxcovr

Tools in R to make it easier to solve the Maximal Coverage Location Problem
http://maxcovr.njtierney.com/
GNU General Public License v3.0
43 stars 12 forks source link

Incorporate summaries into max_coverage #17

Closed njtierney closed 7 years ago

njtierney commented 7 years ago

To save me having to use separate summary functions, I need to include calculation of summary information in extract_mc_results.

I also need to be careful and more clever with the calculation of the summaries, in particular getting the distances calculated appropriately.

These are really slow at the moment as I do an epic joining approach, whereas I could probably write some nicer code in c++ to handle the summary statistics.

A few extra notes

# Some sort of summary table that returns the following columns
# n_added (n_added)
    # This is taken from mc_model$n_added
# **n_added_location (for each urban/rural)**
    # This is taken from group_by(mc_model,first(n_added))
# **location (is it urban/rural/overall)**
    # This is taken from group_by(mc_model) + ungroup()
# **n_ohca (number OHCA events that occured)**
    # This is taken from nrow(mc_model$user)
# n_ohca_cov (number of OHCA events that are covered)
    # nrow(mc_model$users_affected) + sum(dat_dist$is_covered)
# total_aeds (total number of AEDs (original AEDs + n_added))
    # nrow(mc_model$facility) + nrow(mc_model$facilities_added)
# pct_ohca_cov
    # (nrow(mc_model$users_affected) + sum(dat_dist$is_covered)) 
    # / 
    # nrow(mc_model$users)
# mean_dist_to_aed
    # round(mean(dat_dist$distance),2)
# sd_dist_to_aed
    # round(sd(dat_dist$distance),2)
njtierney commented 7 years ago

Done in commit https://github.com/njtierney/maxcovr/commit/686d88e7f1d2b6f8ea3b00bb8521de011e573ede