2

I'd like to create a function to accept indefinite number of arguments. Is there a way to define a function in R?

Thanks.

l0o0
  • 773
  • 1
  • 9
  • 26
  • we will need to know why you need a such a function and what it is supposed to return to give a sensible answer. – Benjamin Jul 27 '15 at 09:12
  • 2
    Probably a dupe of [this](http://stackoverflow.com/questions/3057341/how-to-use-rs-ellipsis-feature-when-writing-your-own-function), not sure though – David Arenburg Jul 27 '15 at 09:27

1 Answers1

2

you can use the dots like this for example

f <- function(...) {
    arguments <- list(...)
    print(arguments)
}

f(a=1, b=2)
## $a
## [1] 1

## $b
## [1] 2
Mamoun Benghezal
  • 5,264
  • 7
  • 28
  • 33