A function that ensures the first argument is always for 'data' - allows greater compatibility with the pipe operator.

data_first(data_obj, fun_to_apply, ...)

Arguments

fun_to_apply

An R function that has a data argument (e.g., stats::lm).

...

Additional arguments for the given function.

data_ob

An R object to pass to a given function's data argument.

Value

The associated output for the fun_to_apply

function.

Examples

data( 'mtcars' )
lm_fit <- data_first( mtcars, lm, formula = mpg ~ cyl )
print( lm_fit )
#> 
#> Call:
#> fun_to_apply(formula = ..1, data = data_obj)
#> 
#> Coefficients:
#> (Intercept)          cyl  
#>      37.885       -2.876  
#>