pipe_function: Wrapper for putting a single function into a pipeline

Description Usage Arguments Value Examples

Description

Wrapper for putting a single function into a pipeline

Usage

1
pipe_function(train, f, ...)

Arguments

train

Data frame containing the train data.

f

The function to be put into the pipeline. It is important that the function can be applied to new datasets without using any information from the train dataset, e.g. lowercasing column names. It should take a data argumet

...

Additional arguments to be provided to f

Value

A list of the transformed train dataset and a .predict function to be used on new data.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
data <- dplyr::data_frame(var = 0, Var = 0, camelCase = 0, good_name = 0,
                          `0none.` = 0, `bad  ` = 0, `j&d` = 0, `spac ed` = 0)
pipe_function(data, standard_column_names)

# You can also use this to append a custom model to the pipeline
data <- dplyr::data_frame(x = 1:10, y = (1:10) + rnorm(10))
model <- lm(y ~ x, data)

self_contained_function <- function(data) predict(model, data)
model_pipe <- pipe_function(data, self_contained_function)

predictions <- invoke(model_pipe$pipe, data)

jeroenvdhoven/datapiper documentation built on July 14, 2019, 9:34 p.m.