TimTeaFan / dplyover

Create columns by applying functions to vectors and/or columns in 'dplyr'.
https://timteafan.github.io/dplyover/
Other
61 stars 0 forks source link

Rename `crossover` and create separate function for cases where a function is supplied as `.y` argument #9

Open TimTeaFan opened 3 years ago

TimTeaFan commented 3 years ago

At the moment crossover has two functionalities:

  1. Its the equivalent to across2x and over2x when an object (vector or list) is supplied to .y
  2. It behaves different, when a function is supplied to .y. In this case the function in .y is applied on all columns in .xcols an the functions in .fns are applied to the resulting return object (of the function in .y being applied to all .xcols).

The behavior in 2. is helpful when creating dummy variables and unique() or dist_values is supplied to .y. However, since the functionality is quite different from what crossover does normally this behavior should be implemented in a separate function, mabye called crossfun().

Further, when a vector or list is supplied to .y then the behavior of crossover resembles to across2x and over2x. Therefore, the current function should be renamed to crossoverx(). I considered this once, but refrained from this naming convention, since it is hard to read and decipher compared to across2x and over2x where we have 2 as a separator. Still at the moment there is no equivalent of crossover to over2 or across2. Originally I thought that this functionality is not much needed, and maybe this really is the case, but introducing a different behavior under a similar name is likely to confuse users. So even if a new sequential crossover might not be used very often, it should still exist and the current function should be renamed to crossoverx, while the .y argument accepting function should be put into a separate function ( crossfun).