Allow 'type.convert' argument in tstrsplit function to support a function/list of functions/named list.#5099
Merged
mattdowle merged 12 commits intoRdatatable:masterfrom Aug 13, 2021
Merged
Conversation
Member
|
LGTM. Great PR. Thanks. |
Contributor
Author
|
Hi @mattdowle |
mattdowle
added a commit
that referenced
this pull request
Aug 14, 2021
mattdowle
added a commit
that referenced
this pull request
Aug 14, 2021
mattdowle
added a commit
that referenced
this pull request
Aug 14, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5094.
In addition to the current behavior of the
tstrsplitfunction, I suggest to extend its features by allowing its 'type.convert' argumentto support a function/list of functions/named list (where its names are functions).
In the case of a named list, the last element may not be named if it is a function.
New features suggested (The pieces of code in the list below are assumed to be the specification of the argument
type.convertof the functiontstrsplit.):if:
1.
type.convert=fun, then the functionfunapplies to each element of the transpose list.2.
type.convert=list(fun), --> same behavior.3.
type.convert=list(fun_1, fun_2, ..., fun_n)and the transpose list has length n, thenfun_1applies to the first element,fun_2to the second element, etc.4.
type.convert=list(fun_1=c(1L, 3L)), thenfun_1applies to the first and third elements (and the remaining elements are kept as is; that is, as character vectors).5.
type.convert=list(fun_1=c(1L, 3L), fun_2=4:5), thenfun_1applies to the first and third elements, andfun_2applies to the fourth and fifth elements (and the remaining elements are kept as is).6.
type.convert=list(fun_1=c(1L, 3L), fun_2=4:5, fun_3), --> same but thefun_3applies to the remaining elements; so they are not kept as is.Any new behavior different from those above is likely unexpected.
Any critic is welcome.
I can also extend or shrink the features above in case there is a need.
To show how these new features work in practice, here are some illustrative examples: