OCHA-DAP / ripc

Download and Tidy IPC and CH Data
GNU General Public License v3.0
2 stars 1 forks source link

ipc_get() - error due to type conversion percentage columns #7

Closed zackarno closed 7 months ago

zackarno commented 9 months ago

ipc_get() creating issues where it can't bind percentage columns together as some are read as "numeric" others as "character"...

issue occurs here:

https://github.com/OCHA-DAP/ripc/blob/bccc53c780639f2100cf214365f5741a14055db6/R/ipc_get.R#L65-L70

I'll open a PR which could be considered a hot temporary fix that deals with this specific column issue, but think we could come up with a more robust dealing with column types 2 ideas that would help:

  1. All to character and the readr::type_convert()
  2. a column type dictionary basically to enforce types based on our knowledge of what they should be
caldwellst commented 8 months ago

So, seems the issue is caused in the nested data frames where there was an instance of a column with just a single 0, causing it to be read as integer rather than character. We can't convert all to character because that would be painful, especially for nest columns which we want to have as lists. So, what I have done is instead ensure that any numeric columns read in are converted to character, while keeping the rest as is.

I then, for each of the functions, made sure that numeric columns present are explicitly returned as numeric. However, I haven't mapped all columns because the IPC API changes so frequently, I didn't think that would be stable. The release to CRAN is #9.