interpolate | R Documentation |
These functions are lightweight wrappers around
glue that make it easier to interpolate
dynamic data into a static prompt. Compared to glue, these functions
expect you to wrap dynamic values in {{ }}
, making it easier to include
R code and JSON in your prompt.
interpolate(prompt, ..., .envir = parent.frame())
interpolate_file(path, ..., .envir = parent.frame())
prompt |
A prompt string. You should not generally expose this to the end user, since glue interpolation makes it easy to run arbitrary code. |
... |
Define additional temporary variables for substitution. |
.envir |
Environment to evaluate |
path |
A path to a prompt file (often a |
A {glue} string.
joke <- "You're a cool dude who loves to make jokes. Tell me a joke about {{topic}}."
# You can supply valuese directly:
interpolate(joke, topic = "bananas")
# Or allow interpolate to find them in the current environment:
topic <- "applies"
interpolate(joke)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.