| aiask | R Documentation |
Automatically discovers compact statistical result components inside an
object, sends only the most useful results to the selected AI service, and
attaches the returned interpretation. Lists receive an ai element; other
objects receive an "ai" attribute.
aiask(x, ai = TRUE, prompt = NULL)
x |
An R4VN result object, summarized list, result table/matrix, or
character result. |
ai |
|
prompt |
Optional request specific to the current result. It is added
after the permanent prompt stored by |
The extractor is generic rather than command-specific. It recursively searches
for result-like tables, matrices, estimates, tests, diagnostics, and short
statistical context while ignoring raw data, HTML/CSS, formatting objects,
plots, model internals, residuals, and other high-volume noise. The same
aiask() can therefore be used for R4VN descriptive, multivariable,
longitudinal, survival, diagnostic, scale, regression, and future result
objects without a separate prepare function for every command.
A conservative input budget is applied before the API call. If the provider
reports that the request is too large, aiask() automatically compacts the
results further and retries up to two times.
Invisibly returns x with an attached AI result. Successful results
contain status, name, model, comment, input, optional usage,
and created. API failures are attached with status = "error" and do not
destroy x.
## Not run:
aisetup(
name = "gpt",
provider = "openai",
model = "gpt-5.6",
tokenenv = "OPENAI_API_KEY",
default = TRUE
)
result <- list(
analysis = "Logistic regression",
outcome = "Hypertension",
estimates = data.frame(
variable = c("Age", "Smoking"),
OR = c(1.05, 1.82),
lower = c(1.02, 1.15),
upper = c(1.08, 2.88),
p = c(0.001, 0.011)
)
)
result <- aiask(result)
result$ai$comment
result <- aiask(
result,
ai = "gpt",
prompt = "Focus on modifiable risk factors."
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.