%-=% | R Documentation |
Updates the left-hand, numeric type object by subtracting the right-hand value from it, reassigning the difference to the left-hand object.
lhs %-=% rhs
lhs |
An numeric object existing in the global/ parent environment. |
rhs |
A numeric value to subtract from the lhs |
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
subtracting the value on the right-hand side.
Returns the arithmetically-updated left-hand object into the environment the operation was performed in.
{
example <- 10
example %-=% 3
example # returns 7
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.