R: += (plus equals) and ++ (plus plus) equivalent from c++/c#/java, etc.?

前端 未结 9 869
攒了一身酷
攒了一身酷 2020-11-29 00:40

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

9条回答
  •  甜味超标
    2020-11-29 01:39

    We released a package, roperators, to help with this kind of thing. You can read more about it here: https://happylittlescripts.blogspot.com/2018/09/make-your-r-code-nicer-with-roperators.html

    install.packages('roperators')
    require(roperators)
    
    x <- 1:3
    x %+=% 1; x
    x %-=% 3; x
    y <- c('a', 'b', 'c')
    y %+=% 'text'; y
    y %-=% 'text'; y
    
    # etc
    

提交回复
热议问题