View source: R/seed_example_helpers.R
| wa_seed_example_models | R Documentation |
This helper writes a minimal model file to a subdirectory of 'dir' (default: 'tempdir()'), and sets the option 'writeAlizer.mock_dir' to that location so examples can run without downloads or network access.
wa_seed_example_models(model = c("example"), dir = tempdir())
model |
Character scalar. Only '"example"' is currently supported. |
dir |
Directory in which to create the example model (default: 'tempdir()'). |
Creates an ultra-tiny model artifact used in examples and points the package loader to it via a temporary option.
- Writes under the supplied 'dir' (by default 'tempdir()') and returns the path. - The example predicts a constant 1.5; it is not a writing assessment. - Sets 'options(writeAlizer.mock_dir = <path>)'; callers should restore prior options when appropriate (see Examples).
(Invisibly) the path to the created example model directory.
local({
old <- options(writeAlizer.mock_dir = NULL)
on.exit(options(old))
parent <- tempfile("wa-example-")
ex <- wa_seed_example_models(dir = parent)
on.exit(unlink(parent, recursive = TRUE), add = TRUE)
predict_quality("example", data.frame(ID = c("text1", "text2")))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.