Description Usage Arguments Details Value Examples
Creates a pipe object out of a function and a list of arguments
1 |
.function |
A function to repeat transformations from a trained pipeline on new data. Will be checked for being a function and taking a |
... |
Other arguments to |
Both .function and all ... arguments are force evaluated upon calling this function. This should guarantee that when calling this function in a clean
environment, it will still be able to use the function and arguments. Any functions that .function depends on will most likely not be included, so library dependencies
aren't taken into account here. The problem here lies in the fact that underlying functions in .function
aren't automatically copied, but lazily evaluated.
See the example for details.
A pipe object with two entries:
predict_function
: A function to repeat transformations from a trained pipeline on new data.
args
: Arguments for predict_function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | # This example should work
dataset <- data.frame(x = 1:10, y= 1:10)
f <- function(data) data[1,]
saved_f <- pipe(.function = f)
without_removing_result <- invoke(saved_f, dataset)
rm(f)
with_removing_result <- invoke(saved_f, dataset)
# This example should fail
g <- function(data) data
f <- function(data) g(data)[1,]
saved_f <- pipe(.function = f)
without_removing_result <- invoke(saved_f, dataset)
rm(f, g)
# The following line will fail
# with_removing_result <- invoke(saved_f, dataset)
# The following is a work-around that currently should function
f <- function(data) {
g <- function(data) data
g(data)[1,]
}
saved_f <- pipe(.function = f)
without_removing_result <- invoke(saved_f, dataset)
rm(f)
with_removing_result <- invoke(saved_f, dataset)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.