Intellipaat 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

1.2k questions

2.7k answers

501 comments

693 users

Browse Categories

...