# R语言吐槽第一弹：等号(=)，还是箭头(<-)

“The best thing about R is that it was developed by statisticians. The worst thing about R is that…it was developed by statisticians.” — Bo Cowgill, Google, Inc

R语言是我自学的第一门计算机语言，虽然接触最早，但用的最不好。因为R是一个面向统计学的高级语言 (statistics-oriented programming language)，有自己独特的数据类型和语法设计。不但在其他语言中难以被借鉴，而且还要记一堆只有在R里才能用到的参数。

There are three different assignment operators: two of them have leftwards and rightwards forms.

The operators <- and = assign into the environment in which they are evaluated. The operator <- can be used anywhere, whereas the operator = is only allowed at the top level (e.g., in the complete expression typed at the command prompt) or as one of the subexpressions in a braced list of expressions.

### 1. 赋值和传参：

> a = 2 #变量赋值
> a
[1] 2


> b <- 2 #变量赋值
> b
[1] 2
[1] TRUE


### 2. 方向性

> b <- 2 #变量赋值
> b
[1] 2
> 3 -> a #变量赋值
> a
[1] 3


### 3. 优先级

x = y = 5
x <- y <- 5
> x
[1] 5
> y
[1] 5


x <- y = 5 // Error in (x <- y) = 5 : object 'x' not found
x = y <- 5
> x
[1] 5
> y
[1] 5