but {operators} | R Documentation |
Modifies the arguments of a function
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>
### 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 )