Skip to content

R is GNU S, not C.... [was "how to get or store ....."]

1 message · Hong Ooi

#
_______________________________________________________________________________________


Hm, a style war on R-Help. I wonder if this goes for long enough, we'll come to the question of where to put the braces. ;)

Personally, I always use <- instead of = where applicable. In addition to the distinction between assignment and naming arguments in function calls, it helps avoid the notorious =/== bug from C programming. Compare

    "if(x == 1) {..." /* comparison -- probably what was wanted */

with

    "if(x = 1) {..."  /* oops */

This has bitten me a number of times in C, so I'd like to avoid it in R/S. Using "if(identical(x, 1)) {..." also addresses this problem, but that just looks awkward to me.