undetermined number of arguments in function r

The solution for “undetermined number of arguments in function r” can be found here. The following code will assist you in solving the problem.

myfun <- function(x, ...) {
    for(i in list(...)) {
        print(x * i)
    }
}

d <- function(...){
    x <- list(...) # THIS WILL BE A LIST STORING EVERYTHING:
    sum(...)
}

# OUTPUT EXAMPLES
        
> d(1,2,3,4,5)
[1] 15

> myfun(4, 3, 1)
[1] 12
[1] 4
> myfun(4, 9, 1, 0, 12)
[1] 36
[1] 4
[1] 0
[1] 48
> myfun(4)

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in