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

Update collapse_col() / collapse_col_flex() #1

Open
1 of 3 tasks
allenbaron opened this issue Feb 23, 2022 · 2 comments
Open
1 of 3 tasks

Update collapse_col() / collapse_col_flex() #1

allenbaron opened this issue Feb 23, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@allenbaron
Copy link
Collaborator

allenbaron commented Feb 23, 2022

  • Add ignore_na parameter
    • Should work for all methods
    • unique already has na.rm parameter --> implement it
    • write wrapper function around first and last
      1. use na.omit
      2. if zero length = return NA of same type, otherwise use first or last

  • Consider implementing ignore_na in _flex() function to account for differential handling of methods
    • boolean = apply to all or none
    • vector (character or named) = apply to specified columns

  • Consider swapping {{ .cols }} with dplyr::everything() in summarize
    • To allow for negative selection to work, e.g. c(-x, -y) --> I want to collapse all columns except x & y
@allenbaron
Copy link
Collaborator Author

It would be nice to make this as flexible as dplyr verbs. These functions are essentially just a group_by() + summarize() operation, so perhaps they should be consolidated & only collapse_col() kept.

The could be done by removing the default method parameter and requiring the use of across() to handle the situation where multiple columns will be 'collapsed'. The biggest change would be the need internally to identify columns specified in across() so that any columns not listed could be added to the group_by() call. Changes to single columns as permitted by collapse_col_flex() would be easy to identify as they'd be named arguments in ....

@allenbaron
Copy link
Collaborator Author

Consider allowing user-defined functions to be used as methods. This would probably need to have a well designed error condition to handle cases where user-defined functions return more than one result per row.

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

No branches or pull requests

1 participant