Description Usage Arguments Value Examples
View source: R/AlgorithmHandler.r
Creates a new Algorithm Handler which registers the onLoad method (which loads the model or other dependencies for the algorithm) and the apply method which takes in the result of the onLoad method and the input from the user.
1 2 3 4 5 | getAlgorithmHandler(
applyfunc,
onLoadMethod = function() { NULL },
pipe = "stdin"
)
|
applyfunc |
The method that we will call synchronously for each algorithm call. The first argument it will be called with is the user input, followed with the output of the onLoad function. |
onLoadMethod |
This optional method that is run once when the process first starts. It loads the data required and other shared state for each algorithm call. |
pipe |
The file which we will read line-by-line to get user input |
A new AlgorithmHandler object
1 2 3 4 5 | loadPrefix <- function() { "Hello" }
algorithm <- function(input, prefix) { paste(prefix, input) }
#To create an algorithm that returns "Hello" + input:
algo <- getAlgorithmHandler(algorithm, loadPrefix)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.