Fabian Scheipl
2009-Jul-30 09:22 UTC
[R] Function match.call or saving all initial parameters
This does what you want:
expand.call <- function(definition = NULL, call = sys.call(sys.parent()),
expand.dots = TRUE)
# like match.call, but with all formal args instead of only the specified
ones
{
ans <- as.list(match.call(definition, call, expand.dots))
frmls <- formals(deparse(ans[[1]]))
add <- which(!(names(frmls) %in% names(ans)))
return(as.call(c(ans, frmls[add])))
}
Best,
Fabian
[[alternative HTML version deleted]]
Fabian Scheipl
2009-Jul-30 09:47 UTC
[R] Function match.call or saving all initial parameters
it doesn't actually- this should work:
expand.call <- function(call=sys.call(sys.parent(1)), expand.dots = TRUE)
# similar to match.call, but with all formal args not the specified ones
only
{
ans <- as.list(call)
frmls <- formals(deparse(ans[[1]]))
add <- which(!(names(frmls) %in% names(ans)))
return(as.call(c(ans, frmls[add])))
}
On Thu, Jul 30, 2009 at 11:22 AM, Fabian Scheipl <
Fabian.Scheipl@stat.uni-muenchen.de> wrote:
> This does what you want:
>
> expand.call <- function(definition = NULL, call =
sys.call(sys.parent()),
> expand.dots = TRUE)
> # like match.call, but with all formal args instead of only the specified
> ones
> {
> ans <- as.list(match.call(definition, call, expand.dots))
> frmls <- formals(deparse(ans[[1]]))
> add <- which(!(names(frmls) %in% names(ans)))
> return(as.call(c(ans, frmls[add])))
> }
>
> Best,
> Fabian
>
[[alternative HTML version deleted]]