Why are there two assignment operators, `<-` and `->` in R?

前端 未结 4 820
我寻月下人不归
我寻月下人不归 2020-12-29 18:31

I know how to use <- and ->, and there are several writeups on the difference between equals assignment & arrow assignment,

4条回答
  •  囚心锁ツ
    2020-12-29 18:52

    R is meant to have a syntax which is fairly natural for expressing mathematics. It is interesting to note that -> is actually common notation in describing some elementary row operations on matrices. For example, s*R_i -> R_i would be used to denote the operation of replacing row i by s times row i. Something like 2*A[1,] -> A[1,] is perfectly valid R. I don't know if these considerations had anything to do with the design decision, but it does show that it is a reasonable choice for a mathematical language.

提交回复
热议问题