0 votes
1 view
in R Programming by (5.3k points)

Does R have a concept of += (plus equals) or ++ (plus plus) as c++/c#/others do?

1 Answer

0 votes
by (25.3k points)

In R, there is no concept of increment operator but you can make a function that performs the same function as an increment operator.

For example:

`++` <- function(x) eval.parent(substitute(x <-x +1))

a <- 1

a

[1] 2

`%+=%` = function(e1,e2) eval.parent(substitute(e1 <- e1 + e2))

x = 1

x %+=% 2 

x

[1] 3

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jul 19, 2019 in R Programming by Ajinkya757 (5.3k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...