bedatadriven / activityinfo-R

ActivityInfo R Language Client
https://www.activityinfo.org/support/docs/R/
17 stars 12 forks source link

Filter argument in `queryTable()` should use R formula syntax #34

Closed Ryo-N7 closed 1 year ago

Ryo-N7 commented 1 year ago

When working inside R, having to also remember the ActivityInfo formula syntax is an extra layer of cognitive load that can be confusing when I'm also working with R formula syntax within other lines of code in the same script.


Nic mentioned checking out how dbplyr does its translations from SQL <> R

might be other interesting packages to draw inspiration from

nickdickinson commented 1 year ago

Here is a possible workflow: getFormSchema(formId) %>% filter(...) %>% rename(...) %>% queryTable() or %>% collect() if we use the language of dbplyr. We would use a type of lazy data from like dbplyr or dtplyr: https://rdrr.io/cran/dplyr/man/filter.html and data masking: https://dplyr.tidyverse.org/reference/dplyr_data_masking.html

When looking at the code of dtplyr, it defines a lazy data table in terms of steps (grouping, filtering, etc.). I guess that for ActivityInfo we would be focusing primarily on filtering data and on renaming columns. Is there anything else? I assume grouping and sorting is not yet supported on the side of the API or that this would come later if so and that mutate and other verbs would require the data.frame to be loaded.

akbertram commented 1 year ago

This has been implemented using dplyr verbs: you can write getRecords() |> filter(Province == 'Nord Kivu') using R syntax to filter on the server.