View source: R/argsFromTrace.R
| argsFromTrace | R Documentation |
This function retrieves stored arguments from a traceit object's attributes and returns those that match the formal arguments of a given function, excluding arguments that were already supplied in the current call.
argsFromTrace(fun, x, attr = "args")
fun |
A function whose formal arguments will be matched against the stored arguments in the traceit object |
x |
An object to extract arguments from. Must inherit from "traceit" class, otherwise an empty list is returned |
attr |
Character string specifying the name of the attribute containing the stored arguments. Default is "args" |
This function is used internally to retrieve default arguments that were
previously stored in a traceit object (via traceit() functions) and
apply them to subsequent function calls. It ensures that explicitly provided
arguments take precedence over stored defaults.
A named list of arguments that:
Match formal arguments of fun (excluding "x")
Were stored in the traceit object's attributes
Were NOT already supplied in the current function call
Returns an empty list if x does not inherit from "traceit" or if
the specified attribute is not a list.
## Not run:
# Assuming a traceit object with stored arguments
p <- traceit(ggplot(mtcars, aes(x = mpg, y = hp)) + geom_point(),
canvas = "wide", formats = "png")
# argsFromTrace would extract canvas and formats if not already specified
args <- argsFromTrace(ggwrite, p)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.