View source: R/schema_generator.R
| create_schema_from_func | R Documentation |
Inspects an R function and generates a z_object schema based on its arguments and default values.
create_schema_from_func(
func,
include_args = NULL,
exclude_args = NULL,
params = NULL,
func_name = NULL,
type_mode = c("infer", "any")
)
func |
The R function to inspect. |
include_args |
Optional character vector of argument names to include. If provided, only these arguments will be included in the schema. |
exclude_args |
Optional character vector of argument names to exclude. |
params |
Optional named list of parameter values to use as defaults. This allows overriding the function's default values (e.g., with values extracted from an existing plot layer). |
func_name |
Optional string of the function name to look up documentation. If not provided, attempts to infer from 'func' symbol. |
type_mode |
How to assign parameter types. "infer" (default) uses default values to infer types. "any" uses z_any() for all parameters. |
A z_object schema.
if (interactive()) {
my_func <- function(a = 1, b = "text", c = TRUE) {}
schema <- create_schema_from_func(my_func)
print(schema)
# Override defaults
schema_override <- create_schema_from_func(my_func, params = list(a = 99))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.