Let's say I have the following function:
foo = function(x, y){
plot(x, y)
}
When I run foo(1:10, 11:20), how do I get the axis labels to say 1:10 and 11:20 rather than x and y?
If that's what you want, you can do
foo = function(x, y, xlab=deparse(substitute(x)), ylab=deparse(substitute(y))){
plot(x, y, xlab=xlab, ylab=ylab)
}
foo(1:10, 11:20)
This will default to the exact values you pass, but you can override by setting explicitly values.
Alternativly, if you just want to essentially change the call from your function to the plot function and pass everything though, you could do something like
foo = function(x, y){
call <- match.call()
call[[1]] <- quote(plot)
eval.parent(call)
}
exists() or missing() but am stuck in figuring out how to search the right environment only. Any suggestion of how to tuck these new parameters internally within the function?