This package provides two simply functions to quickly collect all arguments inside one function and then either

- iterate on one specific argument or
- pass them all to another function.

```
library(collectArgs)
library(magrittr)
sample_function <- function(x, base, thresh=500, verbose=TRUE) {
some_object <- is.na(x) ## an example of an object that we will exclude
another_object <- 1:10 ## an example of an object that we will exclude
if (length(x) > 1) {
return(iterateWithArgs(x, FUNC=sample_function, except=c("some_object", "another_object")))
}
ret <- (base ^ x)
if (verbose)
cat(base, "^", x, " is ", ifelse(ret > thresh, "", "NOT "), "larger than ", thresh, "\n")
return(ret)
}
sample_function(5, base=2)
```

```
## 2 ^ 5 is NOT larger than 500
```

```
## [1] 32
```

```
sample_function(5:10, base=2)
```

```
## 2 ^ 5 is NOT larger than 500
## 2 ^ 6 is NOT larger than 500
## 2 ^ 7 is NOT larger than 500
## 2 ^ 8 is NOT larger than 500
## 2 ^ 9 is larger than 500
## 2 ^ 10 is larger than 500
```

```
## [[1]]
## [1] 32
##
## [[2]]
## [1] 64
##
## [[3]]
## [1] 128
##
## [[4]]
## [1] 256
##
## [[5]]
## [1] 512
##
## [[6]]
## [1] 1024
```

Feedback is greatly appreciated and all pull requests are considered. Please visit on the Package Homepage on github