wpgp / wopr

An R package and Shiny application to provide API access to the WorldPop Open Population Repository (WOPR)
https://apps.worldpop.org/woprVision
GNU General Public License v3.0
36 stars 7 forks source link

local query of agesex populations #33

Open wcjochem opened 3 years ago

wcjochem commented 3 years ago

Hi,

I was trying to query only a single age-sex group using a local SQL database. In getPopSql() here: https://github.com/wpgp/wopr/blob/master/R/getPopSql.R#L73 the code collapses to a vector when agesex_select has a length of 1 (e.g. 'm0'). If you add the option drop = FALSE to the data frame that will preserve the 2 dimensional structure that apply expects. Happy to submit a quick pull request with the change, if you'd like.

wcjochem commented 3 years ago

Hi @edarin,

And a follow-up related question... is the standard/expected format for an age-sex table documented? Again when I'm using getPopSql() that same line of code (from above) is expecting row numbers to match the IDs of the table. Could there be a check for that or an option for a user to instead supply a column identifying the age-sex region? Thanks.

edarin commented 3 years ago

Ha - sorry I didn't get notified previously. I'm looking at it now.