Define `+ =` in R

C and VB.NET (and possibly some others) have convenient functions for incrementing a variable. For instance:.

x = 3 x +=5 # x now equals 8 

Is there any way to define such an operator in R? I tried:

 `+=` <- function(x, y){x <<- x + y} 

but not joy. This was based on the answer to this question .

+5
source share

All Articles