Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to support extensions of dplyr verbs in galah #161

Closed
mjwestgate opened this issue Oct 20, 2022 · 2 comments
Closed

Option to support extensions of dplyr verbs in galah #161

mjwestgate opened this issue Oct 20, 2022 · 2 comments
Assignees

Comments

@mjwestgate
Copy link
Collaborator

At a recent webinar, @huizezhang-sherry suggested that we could implement extensions dplyr functions pretty easily, given that our functions use the same methods and terminology anyway. E.g. instead of:

galah_call() |> 
  galah_filter(year >= 2020) |>
  atlas_counts()

We could then use:

galah_call() |> 
  filter(year >= 2020) |>
  atlas_counts()

The approach is documented here.

Some other thoughts:

  • select/galah_select, group_by/galah_group_by obvious extensions
  • Other functions may not have a dplyr equivalent but could have alternate names, e.g. identify/galah_identify (also an S3 function from graphics) or apply_profile/galah_apply_profile
  • Some things that are currently arguments could be replaced by functions, e.g. atlas_counts(expand = TRUE) could be replaced by expand() |> atlas_counts() (currently an S3 method in tidyr)
mjwestgate added a commit that referenced this issue Oct 27, 2022
Test with `filter` as synonym for `galah_filter`. In theory this should work already; but in practice I get:
```
galah_call() |> filter(year > 2020) |> atlas_counts()
Error in UseMethod("filter") :
  no applicable method for 'filter' applied to an object of class "data_request"
```
mjwestgate added a commit that referenced this issue Nov 1, 2022
This code should work; but again the problem here is how to get R to recognise that an S3 method exists, which is partly about NAMESPACE and partly about `roxygen2`. Sometimes this works, other times it fails. Super annoying
mjwestgate added a commit that referenced this issue Nov 1, 2022
Move code to new files `filter.R` and `select.R`, re-add `@exportS3Method` tag, manually remove incorrect tags from NAMESPACE then rebuild using `document()`
mjwestgate added a commit that referenced this issue Nov 2, 2022
`group_by` is a synonym for `galah_group_by`, but with `expand = TRUE` hard-coded. `summarise` is a synonym for `atlas_counts`.
mjwestgate added a commit that referenced this issue Nov 2, 2022
As a side-effect, `limit` is now `NULL` by default
@mjwestgate
Copy link
Collaborator Author

mjwestgate commented Nov 2, 2022

Note to self to support slice_head() to atlas_occurrences() using pageSize arg in new API. Using the start arg it might be possible to support slice() as well.

On a related note; technically we've implemented slice_max() so far, despite calling it slice_head(), because solr ranks in decreasing order of count by default. To choose between these would could use fsort=count for slice_max() or fsort=index for slice_head(). Optionally we could add dir=asc to implement slice_min() & slice_tail()

mjwestgate added a commit that referenced this issue Nov 17, 2022
+ fixes to documentation etc requested by `check()`
mjwestgate added a commit that referenced this issue Nov 17, 2022
Since adding `importFrom dplyr function` to each file, this wasn't actually doing anything other than generating an error. However, `exportS3Method` is still recommended in some documentation, so it's unclear why this approach is better
mjwestgate added a commit that referenced this issue Nov 21, 2022
not from `dplyr`, but works in the same way
@mjwestgate mjwestgate self-assigned this Nov 28, 2022
mjwestgate added a commit that referenced this issue Nov 28, 2022
Added new `parse_select` function to do most of the work
mjwestgate added a commit that referenced this issue Nov 29, 2022
Given that we only use on function from `data.table`, the only thing stopping us from replacing it was the number of dependencies associated with `dplyr`. This is no longer an issue as we import `dplyr` to access other functions, such as `filter`, `select` and `group_by` (#161)
mjwestgate added a commit that referenced this issue Nov 29, 2022
Also update documentation to refer to `dplyr` verbs when `?galah` is called
mjwestgate added a commit that referenced this issue Nov 30, 2022
mjwestgate added a commit that referenced this issue Nov 30, 2022
Mainly referring back to their synonymous functions.
@mjwestgate
Copy link
Collaborator Author

complete

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant