We had recently back-ported a Python sklearn Pipeline step style interface from the Python vtreat to R (announcement here). But that doesn’t mean we are not continuing to make enhancements to the R style interfaces, using features that are unique to R.
With the upcoming wrapr unpacking features we can re-write use of vtreat’s
mkCrossFrame*Experiment() cross-frame interfaces from this:
cross_frame_experiment <- mkCrossFrameCExperiment( d, varlist = varlist, outcomename = outcomename, outcometarget = outcometarget) # unpack the items we want from returned list treatments <- cross_frame_experiment$treatments cross_frame <- cross_frame_experiment$crossFrame
varlist = varlist,
outcomename = outcomename,
outcometarget = outcometarget) %.>%
treatments <- treatments, cross_frame <- crossFrame ]
In our first unpack note we mentioned there were R functions that returned named lists. The vtreat
mkCrossFrame*Experiment() functions are just that: functions that return named lists. Functions that return named lists/classes really call out for a named multiple assignment operator (for a positional multiple assignment operator see zeallot, and for a different named multiple assignment system see also vadr).
The assignments in a unpacking block (currently written as:
unpack) can use any of the R local assignment-like operators (
:=). And we have the convention that a name alone such as “
a” is shorthand for “
a <- a“. These unpack operators now look like a full named multi-assignment system for R.
Below is a small stand-alone example of the assignment notation.
a_variable <- a_value, b_variable <- b_value ] <- list(a_value = 1, b_value = 2) a_variable #>  1
#>  2
We are working on a new vignette about named multiple assignment here.