%+=% {infixit} | R Documentation |
Addition variable reassignment
Description
Updates the left-hand, numeric type object by adding the right-hand value to it, reassigning the sum to the left-hand object.
Usage
lhs %+=% rhs
Arguments
lhs |
An numeric object existing in the global/ parent environment. |
rhs |
A numeric value to add to the sum |
Details
Currently in R, if you want to update the value
of a numeric object to be the outcome of some
arithmetic operation, you have to initialize the
object and then reassign it. For example:
apple <- 1
and then apple <- apple + 1
. This
sort of thing is generally referred to as
augmented variable assignment. This function allows
users to update the value of an object through
adding the value on the right-hand side.
Value
Returns the arithmetically-updated left-hand object into the environment the operation was performed in.
Examples
{
example <- 5
example %+=% 8
example # returns 13
}
[Package infixit version 0.3.1 Index]