Description Usage Arguments Details Author(s) See Also Examples
From the ... argument used in your function, find if a specific
argument was included and extract its value.
1 |
name |
Name of the advanced argument to look for in |
value |
The default value of the advanged argument. If this advanced
argument is used in several of your functions, we recommend using
|
... |
Advanced arguments. See dotsMethods. |
Note that you can make dots() even more powerful by using getOption
to define value. This is particularly useful if you use the
same advanced argument in several functions.
L. Collado-Torres
dotsMethods
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | ## Simple example that calculates the max between 'x' and 'y' with a
## specified minimum value to return.
minMax <- function(x, y, ...) {
minValue <- dots('minValue', 0, ...)
res <- max(x, y, minValue)
return(res)
}
minMax(1:2, 3:4)
minMax(1:2, 3:4, minValue = 5)
## See the function 'last' included in this package.
## It's an example where most users don't need the 'selector' argument
## but the experienced users can find it and use it.
last
## Examples using this function
l <- list(a = 1:10, b = 11:20)
last(l)
last(l, selector = '[[')
## A more complicated example is 'recursive_last' where we specifically
## define the 'selector' argument that is the then passed to 'last'
recursive_last
## Example usages of 'recursive_last'
l2 <- list(j = 21:30, k = list(a = 1:10, b = 11:20))
recursive_last(l2)
recursive_last(l2, level = 2L, selector = '[[')
recursive_last(l2, level = 3L, selector = '[[')
recursive_last(l2, level = 2L, selector = c('[', '[['))
## Arguably these examples are simple, but the idea is that dots()
## can simplify very long function calls where some parameters will be used
## by a minority of the users.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.