Question Details

No question body available.

Tags

r function arguments substitution

Answers (2)

Accepted Answer Available
Accepted Answer
April 29, 2025 Score: 5 Rep: 11,823 Quality: High Completeness: 50%

Your question contains a lot of design questions.

I am not too sure what you want. Quick-fix (dirty)

.myfunction = \(a, n) a + n^2L # . to indicate internal use

wrapper = \(value, func, arg.name, ...) { args = list(...) args[[arg.name]] = value do.call(func, args) }

> wrapper(value=4, func=.myfunction, arg.name='n', a=3)
[1] 19

I do not see much sense behind this.

April 29, 2025 Score: 6 Rep: 12,218 Quality: High Completeness: 60%

You can use substitute() to create an unevaluated call to the supplied FUNC with ... expanded. Then add the VALUE as a named argument to the call using the ARG.NAME. Finally evaluate the constructed call in the caller’s environment.

EXISTING.FUNCTION