Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
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
edited by

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

Browse Categories

...