Description Usage Arguments Value Note Author(s) See Also Examples
Modifies the arguments of a function
1 | fun %but% x
|
fun |
Function to modify |
x |
Modifier |
A function with the same body as the fun argument but
with a different list of arguments.
The %but% operator is S3-generic with the following methods:
- A default method which does nothing more than returning the fun function.
- A charactor method. In that case, x describes the logical
arguments of the function. x is a single character string containing
one or several token of the form ab where b is the first
letter of the logical argument we wish to modify and a is
an optional modifier. a can be empty or +, in which
case the argument will be set to TRUE; - in which case the
argument will be set to FALSE; or ! in which case the
argument will be the opposite of the current value in fun
- A list. In that case, arguments that are part of the formal
arguments of fun and elements of the list x are
updated to the element in x
Romain Francois <francoisromain@free.fr>
args, formals
1 2 3 4 5 6 7 8 9 10 11 12 |
### default method, nothing is done
rnorm %but% 44
### character method, operating on logical arguments
grep %but% "pf" # grep, with perl and fixed set to TRUE
grep %but% "i-e" # grep, ignoring the case but not using extended regular expressions
( grep %but% "vp" )( "blue", colors() )
### list method
rnorm %but% list( mean = 3 )
rnorm %but% list( nonsense = 4 )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.