decr {refer} | R Documentation |
Decrease Value In Place
Description
Decrease the value of an object on the search path. Equivalent to x--
or
x -= by
in other languages. See incr
for details on implementation.
Usage
decr(x, by = 1)
Arguments
x |
object to be decreased; can be a symbol, character, or extraction language object. |
by |
value to decrease |
Value
the value of x
decreased by by
, invisibly
Examples
z <- 1:10
incr(z)
identical(z, 2:11) # TRUE
incr(z[1:3], by=2)
identical(z[1:3], 4:6) # TRUE
l <- list(a = 1, b = 2)
decr(l$a)
l$a == 0 # TRUE
decr(l$b, by = 4)
l$b == -2 # TRUE
[Package refer version 0.1.0 Index]