create_call: Create a call for a function

Description Usage Arguments Details Value

View source: R/create_call.R

Description

Based on arguments delivered by the dotsMethods, i.e. ..., or by a list or by an environment, this function will create a call for the specified function.

Usage

1
create_call(.cc_fun, ..., .cc_list = FALSE, .cc_ignore = NULL)

Arguments

.cc_fun

The targeted function, either given directly or as a name or character.

...

dotsMethods, the arguments to be used in the creation of our call of .cc_fun. If the arguments of interest already are stored in a list (or an environment), set the argument .list to TRUE. Note that the arguments given by this procedure must have names matching those of the function, in order for them to be properly included. It's not required that all the arguments of the function should be specified. Any unnamed arguments will be given a dummy name if .cc_fun use 'dotsMethods'.

.cc_list

Logic value , default FALSE. This can be used when the arguments already are contained in a list or an environment. NOTE: Only the first argument given to ... will in this case be recorded!

.cc_ignore

Character vector, default value NULL. When the arguments we want to create our call are delivered in a list or an environment, this can be used to perform a partially update, i.e. give the names of the arguments we don't want to update (yet).

Details

A call can simplify code at one point of a function at the cost of including some "ugly" code somewhere else (in particular if it is constructed from scratch). The function do.call will add everything from the list given to argument args to the function, and the evaluate it. Unless the targeted function use the dotsMethods, i.e. ..., this requires that the list of arguments must be fine-tuned to the function (or else an error pointing out some unused arguments will pop-up). An approach using as.call might be used, but once again everything will be added as arguments, which implies that the resulting call must be adjusted before evaluation. The present function doesn't add any superfluous arguments to the targeted function, and thus simplifies the task of creating and using calls when programming, which often can make the code much leaner.

Value

The result of this function is a call based on .cc_fun and relevant arguments. Warning: The present incarnation of the code does not test that all mandatory arguments are included, so it's no guarantee that a call created by a nitwit will execute.


LAJordanger/leanRcoding documentation built on Feb. 27, 2020, 4:42 p.m.