all, this may sound dummy, but I need to understand some legacy R code while I know nothing of it. I hope someone could give me some hint on what's going on below:
g = if (calc.tstat){
function(...) FUN(...)} else
{function(...) FUN(..1)}
These 3 lines are part of a function (famamacb) called by below:
temp <- famamacb(include = include,
function(coef) list(tseries.tstat = apply(coef,2, cumtstat, na.rm = T, i =
match(rownames(coef), rownames(time.weight)))))
My understanding is FUN(...) refers to the function(coef), which generates a list. Could someone correct me if I'm wrong? But what does FUN(..1) do then?
Thanks much in advance!
CodePudding user response:
..1
refers to the first element from the variable number of arguments supplied through the ellipsis argument (see also help("...")
for more information).
Here is a minimal example, showing how ..2
refers to the second element from the arguments supplied through ...
.
f <- function (x, ...) return(c(x, list(..2)))
f("zero", "one", "two")
#[[1]]
#[1] "zero"
#
#[[2]]
#[1] "two"