| but {operators} | R Documentation |
Modification of function arguments
Description
Modifies the arguments of a function
Usage
fun %but% x
Arguments
fun |
Function to modify |
x |
Modifier |
Value
A function with the same body as the fun argument but
with a different list of arguments.
Note
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
Author(s)
Romain Francois <francoisromain@free.fr>
See Also
Examples
### 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 )